Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.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
Javascript 不是jQuery链中下一个元素上的选择器_Javascript_Jquery_Html_Chain - Fatal编程技术网

Javascript 不是jQuery链中下一个元素上的选择器

Javascript 不是jQuery链中下一个元素上的选择器,javascript,jquery,html,chain,Javascript,Jquery,Html,Chain,我有一系列方法可以在li中找到ul,并设置其高度的动画 $('.collapse-trigger').click(function() { if($(this).next('.collapse-ul').height() == 0) { $(this).css('background', '#000000'); var height = $(this).next('.collapse-ul').children().length; $(

我有一系列方法可以在
li
中找到
ul
,并设置其高度的动画

$('.collapse-trigger').click(function() { 
    if($(this).next('.collapse-ul').height() == 0) {
        $(this).css('background', '#000000');
        var height = $(this).next('.collapse-ul').children().length; 
        $(this).next('.collapse-ul').animate({height: height*42}, 500); // multiply height with number of menupoints
    }
    else { 
        $(this).css('background', '#414141');
        $(this).next('.collapse-ul').animate({height: 0}, 500);
    }
});
有了这个,我可以折叠每个
ul
,然后再次单击,它就会回到
0
。我打算做的是,当一个
ul
正在进行动画制作时,其他的动画制作回到零

我想我需要像
这样的东西。不是(这个)
,而是与之斗争。 我的尝试:

$('this').next().not('.collapse-ul', this).animate({height: 0}, 500); // <-- inside the not method I don't know how to write it

$('this').next().not('.collapse ul',this.).animate({height:0},500);// 试试这个:您可以先找到可折叠的ul,然后使用
.not()


你能发布你的HTML吗。。??或者一个演示会很棒…谢谢,它很接近,唯一的一点是,它将所有其他动画设置为零,然后扩展所有动画。我是否遗漏了一个阻塞变量?编辑:无需担心,它正在工作……)
$('.collapse-trigger').click(function() { 
    if($(this).next('.collapse-ul').height() == 0) {
        $(this).css('background', '#000000');
        var height = $(this).next('.collapse-ul').children().length;
        var $collapseUl = $(this).next('.collapse-ul');
        //filter current collapsible ul
        $('.collapse-ul').not($collapseUl).animate({height: 0}, 500); 
        $collapseUl.animate({height: height*42}, 500); // multiply height with number of menupoints
    }
    else { 
        $(this).css('background', '#414141');
        $(this).next('.collapse-ul').animate({height: 0}, 500);
    }
});