Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
52
rated 0 times [  58] [ 6]  / answers: 1 / hits: 16260  / 13 Years ago, sun, april 24, 2011, 12:00:00

Markup:



<div>
<h3 class = trigger>Heading 1</h3>
<ul class = toggle>
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class = trigger>Heading 2</h3>
<ul class = toggle>
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>


and the JQuery:



$(.toggle).slideUp();
$(.trigger).click(function(){
$(.toggle).slideToggle(slow);
});


I'd like to be able to toggle these <ul>s independently. Currently, when either <h3> title is clicked both divs toggle...



code is at: http://jsfiddle.net/CPvCZ/4/


More From » jquery

 Answers
6

The solution is quite simple:



$(.toggle).slideUp();
$(.trigger).click(function(){
$(this).next(.toggle).slideToggle(slow);
});


http://jsfiddle.net/CkTRa/


[#92591] Thursday, April 21, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
luna

Total Points: 698
Total Questions: 114
Total Answers: 93

Location: Israel
Member since Wed, Apr 14, 2021
3 Years ago
luna questions
;