Is there a better way to write this in jQuery? - by user302805 $(".sectionHeader").click(function() { var row = $(this).parent(); while (row.next().length != 0) { row = row.next(); if (row.children().first().is('th')) return; row.toggle(); } }); Read the article