Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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
有没有更好的方法来为这个accordian构建这个jquery?_Jquery_Css_Performance - Fatal编程技术网

有没有更好的方法来为这个accordian构建这个jquery?

有没有更好的方法来为这个accordian构建这个jquery?,jquery,css,performance,Jquery,Css,Performance,我知道你可以使用jqueryaccordio函数来实现这一点,但我正在尝试另一种方法 你可以看到我在这里拼凑的代码 有没有更好的方法来构造jquery $('.acchead').click(function(){ //check if already open othwerwise... if (!$(this).next().hasClass("sel")){ //remove the initially opened item if($(this).next().

我知道你可以使用jqueryaccordio函数来实现这一点,但我正在尝试另一种方法

你可以看到我在这里拼凑的代码

有没有更好的方法来构造jquery

$('.acchead').click(function(){
  //check if already open othwerwise...
  if (!$(this).next().hasClass("sel")){
    //remove the initially opened item
    if($(this).next().hasClass("init")){
      $(this).next().removeClass('init');
    }
   //close all items, remove any selected classes, open clicked item 
   $('.sel').slideUp();
   $('.acc .sel').removeClass('sel');
     $(this).next().slideDown().addClass('sel');
  }
});

干杯

您最好将问题提交给:您可以避免对所有元素进行分解。您可以使用标题、段落和分段元素,还可以定义一个名为is_busy的变量,通过该变量,您可以确定是否存在活动的动画,然后阻止新动画执行或将其放在一行中。那会使你的工作做得更好。你知道如果你快速点击一些标题,你就不会等到动画结束。