I use this on the page:
jQuery('.class1 a').click( function() { if ($(".class2").is(":hidden")) { $(".class2").slideDown("slow"); } else { $(".class2").slideUp(); } });
With the structure on the page, it will later look like this:
<div class="class1"> <a href="...">text</a> <div class="class2">text</div> </div>
This works just fine unless you have multi-level classes class1 / class2:
<div class="class1"> <a href="...">text</a> <div class="class2">text</div> </div> <div class="class1"> <a href="...">text</a> <div class="class2">text</div> </div> <div class="class1"> <a href="...">text</a> <div class="class2">text</div> </div>
How to change jquery source code so that it only affects class2 under the current class1 that was clicked? I tried the options of what was recommended on this page: How to get children from the $ (this) selector? but havent got him to work yet
jquery css-selectors children
Orbalon May 08 '09 at 20:03 2009-05-08 20:03
source share