Toggle siblings with jquery -
i have problems toggle() in jquery. see http://jsfiddle.net/rch7l/. when clicking level-1 header should, when clicking level-2 header opens level-3 row , not level-3 rows under level-2 header.
$('tr.level-2, tr.level-3').css("display", "none"); $("tr.level-1").click(function(){ $(this).siblings('tr.level-2').toggle(); }); $("tr.level-2").click(function(){ $(this).siblings('tr.level-3').toggle(); });
i've tried using siblings(), not want when clicking level-2 headers.
simply use .nextuntil()
method
$("tr.level-2").click(function(){ $(this).nextuntil('tr.level-2').toggle(); });