We help IT Professionals succeed at work.
Get Started

Toggle multiple DIV on and off.

openinterface
on
2,436 Views
Last Modified: 2012-05-05
Hi,

I have 5 divs which get displayed depending on what  heading is hovered over.  I want this popup to remain open until another selection is made, the previously opened DIV should be closed when a new selection is made.  Only one div should be open at a time.  The following code shows/hides them okay, but they dont stay open.
<script type="text/javascript">
  $(document).ready(function(){
  
  var $curr = $("#start");
    
  $(".msg_body").hide();
    
    $(".msg_head").hover(
      function () {
	  
	  $curr = $curr.prev();
	  
 
        $(this).next("$curr").show();
 
 
      }, 
      function () {
     $(this).next("$curr").hide();
      }
    );
	
  });
  
  </script>
 
<div id="goal1">
<div id="msg_list">
<p class="msg_head"><img src="images/goal1.gif" alt="Goal 1 Benchmarking" name="goal1" width="285" height="49"></p>
  
 
<div class="msg_body">
<strong>Goal 1</strong>Text text</div>
  </div>  
</div>

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE