• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

modify jquery to allow multiple control panels to remain open?

Hi. I have set up an accordion menu, per this page: http://jqueryui.com/demos/accordion/

However, I need to allow more than one control panel to stay open at the same time. I am trying to use this code:

jQuery(document).ready(function(){
	$('.accordion .head').click(function() {
		$(this).next().toggle();
		return false;
	}).next().hide();
});

Open in new window


... or something like it, to allow more than one control panel to stay open. But, it's not working for me.

Is there an easy way to modify the jquery code (below) to allow more than one control panel to stay open? Or should I abandon this jquery code and look for another?

Thank you for your help.

Eric


<!DOCTYPE html>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" />

<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>


<script type="text/javascript">
var section = "demos/accordion";
</script>

<script type="application/javascript">
	$(function() {
		$( "#accordion" ).accordion();
	});
</script>


<div class="demo">

<div id="accordion">
	<h3><a href="#">Section 1</a></h3>
	<div>
		<p>
		Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
		ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
		amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
		odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
		</p>
	</div>
	<h3><a href="#">Section 2</a></h3>
	<div>
		<p>
		Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
		purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
		velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
		suscipit faucibus urna.
		</p>
	</div>
	<h3><a href="#">Section 3</a></h3>
	<div>
		<p>
		Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
		Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
		ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
		lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
		</p>
		<ul>
			<li>List item one</li>
			<li>List item two</li>
			<li>List item three</li>
		</ul>
	</div>
	<h3><a href="#">Section 4</a></h3>
	<div>
		<p>
		Cras dictum. Pellentesque habitant morbi tristique senectus et netus
		et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
		faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
		mauris vel est.
		</p>
		<p>
		Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
		Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
		inceptos himenaeos.
		</p>
	</div>
    
</div><!-- End accordion -->

</div><!-- End demo -->

Open in new window

0
Eric Bourland
Asked:
Eric Bourland
  • 2
1 Solution
 
Jen0910Commented:
I use this to do similar to what you are mentioning. It has everything closed initially but will open them one by one without closing any previously opened.

<script type="text/javascript">
         $(document).ready(function() {
                    $('div#accordion> div').hide();  
                    $('div#accordion> h3').click(function() {
                      $(this).next('div').slideToggle('slow')
                      .siblings('div:visible').slideDown('slow');
                    });
            });
                  </script>
          <div id="accordion">
          <h3>Section title</h3>
          <div>section content</div>
          </div>
0
 
Eric BourlandAuthor Commented:
Works like a charm. Thank you, Jen. Happy halloween! Eric
0
 
Jen0910Commented:
No problem--likewise, and thanks for the points.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now