Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4557762
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:33:15+00:00 2026-05-21T17:33:15+00:00

I have 4 equally spaced boxes in a page. I want to be able

  • 0

I have 4 equally spaced boxes in a page. I want to be able to click on one and it expand to fit in the area of 2, while hiding the one to the right. The code below allows me to click on .box1 and expand box1 / hide box2 to fill 2 box spaces. The problem is, when I click box1 to close to original size it does not put box2 back like it should. Here is the code so far:

$(function() {


    $( ".box1" ).click(function() {
    $( ".box1" ).switchClass( "box1", "box1_l", 200 );
    $( ".box1_l" ).switchClass( "box1_l", "box1", 200 );
    $(".box2").hide();

        return false;
    });

$(function() {

    $( ".box1_l" ).click(function() {
    $( ".box2").show();
        return false;
    });

});

thank you in advance 🙂

RESOLVED THANKS TO CYBERNATE:

$(function() {
$( ".box1" ).click(function() {
    var $box2 = $(".box2");
    if($box2.is(":visible")){
        $( ".box1" ).switchClass( "box1", "box1_l", 200 );
        $( ".box1_l" ).switchClass( "box1_l", "box1", 200 );
        $(".box2").hide();
        return false;
    } else{
    $( ".box2").show();
     $( ".box1_l" ).switchClass( "box1_l", "box1", 200 );

 return false;
    }
}); 

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:33:15+00:00Added an answer on May 21, 2026 at 5:33 pm

    Try this:

    $(function() {
        $( ".box1" ).click(function() {
            var $box2 = $(".box2");
            if($box2.is(":visible")){
                $( ".box1" ).switchClass( "box1", "box1_l", 200 );
                $( ".box1_l" ).switchClass( "box1_l", "box1", 200 );
                $(".box2").hide();
                return false;
            } else{
                 //Not sure if you need the two commented lines below.   
             //$( ".box1" ).switchClass( "box1_l", "box1", 200 );
             //$( ".box1_l" ).switchClass( "box1", "box1_l", 200 );
             $( ".box2").show();
         return false;
            }
        }); 
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a template which has 3 equally spaced boxes, the problem is that
I have a long-standing application that I'm normally able to compile equally well from
Trying to have a horizontal navigation bar that has equally spaced links spanning across
I have this histogram which counts the array d in equally log-spaced bins. max_val=np.log10(max(d))
I have 25 2D images (of equal size), each image represents one layer equally
I'd like this to have equally-spaced columns. In an older version, it worked, but
I have TortoiseSVN installed and it works great. Would like to have an equally
Have deployed numerous report parts which reference the same view however one of them
have 2 questions : A computer with 32-bit address uses 2-level page table (9
i have given points of 2 lines. The x values are non equaly spaced.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.