Jquery 尝试使用.not(this)隐藏类名为的所有其他元素

Jquery 尝试使用.not(this)隐藏类名为的所有其他元素,jquery,Jquery,试图隐藏所有其他项,但它会继续影响$(此)项 也不是 正在为我工作。试试。not(“#”+$(this.attr('id'))$(this.sibbins().hide(600)一直在我的函数中找到答案 $(function() { $(".FL-pest-indv").css({ display: 'none' }); $(".FL-pest-cat").live('click', function() { $(".FL-pest-indv").not($(this).children

试图隐藏所有其他项,但它会继续影响$(此)项

也不是


正在为我工作。

试试。not(“#”+$(this.attr('id'))

$(this.sibbins().hide(600)
一直在我的函数中找到答案

$(function() {
$(".FL-pest-indv").css({ display: 'none' });
$(".FL-pest-cat").live('click',
function() {
    $(".FL-pest-indv").not($(this).children('.FL-pest-indv')).hide(600);
    $(this).children('.FL-pest-indv').stop(true, true).animate({ "height": "toggle" ,   "opacity" : "toggle"},600);
    });
});

你能复制这个吗?html输出太大了,这里有一个JFIDLE链接:它大部分都在工作,但是当你点击打开的父项时,它只是重新打开而不是关闭。我看不出代码有什么问题。如果你扩展一个,然后再次单击扩展的一个,它似乎会工作,但它不会关闭。$(这个)不会作为字符串。是的,我知道它不会-但是$(这个)。attr('id')最肯定是(所以我不明白为什么这会导致否决票,但不管怎样)。他也在使用类,所以它必须是
。而不是(“。”+$(这个)。attr('class'))
开始工作。所以,是的,否决票。即使设置为影响班级,这也不起作用。原始代码可以工作,除非你点击当前打开的类的父类,然后它就可以重新打开它。还有-你真的没有在这里使用ID吗?如果是这样的话,那么乔纳是正确的,因为这个原因,我最初的建议不起作用。我假设正在使用ID。这只是开始隐藏其他所有内容,即.FL pest catI希望它隐藏.FL pest indv的所有其他实例
$(function() {
$(".FL-pest-indv").css({ display: 'none' });
$(".FL-pest-cat").live('click',
function() {
    $(".FL-pest-indv").not(this).hide(600);
    $(this).children('.FL-pest-indv').stop(true, true).animate({ "height": "toggle" ,   "opacity" : "toggle"},600);
        }); 
        });
$(function() {
$(".FL-pest-indv").css({ display: 'none' });
$(".FL-pest-cat").live('click',
function() {
    $(".FL-pest-indv").not($(this).children('.FL-pest-indv')).hide(600);
    $(this).children('.FL-pest-indv').stop(true, true).animate({ "height": "toggle" ,   "opacity" : "toggle"},600);
    });
});