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

live demo

$("tr.level-2").click(function(){     $(this).nextuntil('tr.level-2').toggle(); }); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -