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 = 开发者_如何学Go"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/
The solution is quite simple:
$(".toggle").slideUp();
$(".trigger").click(function(){
$(this).next(".toggle").slideToggle("slow");
});
http://jsfiddle.net/CkTRa/
精彩评论