Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui 有没有更好的方法在jQuery中编写这个?_Jquery Ui_Jquery_Jquery Selectors - Fatal编程技术网

Jquery ui 有没有更好的方法在jQuery中编写这个?

Jquery ui 有没有更好的方法在jQuery中编写这个?,jquery-ui,jquery,jquery-selectors,Jquery Ui,Jquery,Jquery Selectors,表中似乎有行是节标题,在这种情况下,可以折叠到下一个节标题,如下所示: $(".sectionHeader").click(function() { $(this).parent().each(function(index, element){ if($(element).children().first().is('th')) return; $(element).toogle(); }); }); $(".sectionHeader").click(

表中似乎有行是节标题,在这种情况下,可以折叠到下一个节标题,如下所示:

$(".sectionHeader").click(function() {
    $(this).parent().each(function(index, element){
      if($(element).children().first().is('th')) return;
      $(element).toogle();
    });
});
$(".sectionHeader").click(function() {
    $(this).closest("tr").nextUntil(".sectionHeader").toggle();
});
使用
delegate()
可以提高效率,如下所示:

$(".sectionHeader").click(function() {
    $(this).parent().each(function(index, element){
      if($(element).children().first().is('th')) return;
      $(element).toogle();
    });
});
$(".sectionHeader").click(function() {
    $(this).closest("tr").nextUntil(".sectionHeader").toggle();
});
这将为整个表附加一个事件处理程序,而不是每
.sectionHeader
行附加一个事件处理程序