Javascript 隐藏不是特定类的元素

Javascript 隐藏不是特定类的元素,javascript,jquery,html,Javascript,Jquery,Html,我想通过jQuerys隐藏一个不是特定类的元素: 在这种情况下,我是否使用了.not()方法错误,因为它似乎不起作用 您的选择器需要 jQuery('.post项') 您需要在jQuery的末尾关闭,如下所示: var thisContent; jQuery('.content-btn').click(function() { thisContent = this.id; jQuery('.post-item').not('.'+thisContent).fadeOut(); }

我想通过jQuerys隐藏一个不是特定类的元素:


在这种情况下,我是否使用了
.not()
方法错误,因为它似乎不起作用

您的选择器需要

jQuery('.post项')

您需要在jQuery的末尾关闭,如下所示:

var thisContent;
jQuery('.content-btn').click(function() {
    thisContent = this.id;
    jQuery('.post-item').not('.'+thisContent).fadeOut();
});

有关工作示例,请参阅。

您的选择器需要

jQuery('.post项')

您需要在jQuery的末尾关闭,如下所示:

var thisContent;
jQuery('.content-btn').click(function() {
    thisContent = this.id;
    jQuery('.post-item').not('.'+thisContent).fadeOut();
});

有关工作示例,请参阅。

您的选择器需要

jQuery('.post项')

您需要在jQuery的末尾关闭,如下所示:

var thisContent;
jQuery('.content-btn').click(function() {
    thisContent = this.id;
    jQuery('.post-item').not('.'+thisContent).fadeOut();
});

有关工作示例,请参阅。

您的选择器需要

jQuery('.post项')

您需要在jQuery的末尾关闭,如下所示:

var thisContent;
jQuery('.content-btn').click(function() {
    thisContent = this.id;
    jQuery('.post-item').not('.'+thisContent).fadeOut();
});
有关工作示例,请参阅。

尝试使用

$(element).hasClass(".clasname").fadeOut();
试用

$(element).hasClass(".clasname").fadeOut();
试用

$(element).hasClass(".clasname").fadeOut();
试用

$(element).hasClass(".clasname").fadeOut();

作为@并最终注意到修改您的选择器。。当您使用click on Anchor时,您需要使用e.preventDefault试试这个

jQuery('.content-btn').click(function(e) {
    e.preventDefault;
    thisContent = this.id;
    jQuery('.post-item').not('.'+thisContent).fadeOut();
    $('.'+thisContent).fadeIn();
});

作为@,最后注意到修改您的选择器。。当您使用click on Anchor时,您需要使用e.preventDefault试试这个

jQuery('.content-btn').click(function(e) {
    e.preventDefault;
    thisContent = this.id;
    jQuery('.post-item').not('.'+thisContent).fadeOut();
    $('.'+thisContent).fadeIn();
});

作为@,最后注意到修改您的选择器。。当您使用click on Anchor时,您需要使用e.preventDefault试试这个

jQuery('.content-btn').click(function(e) {
    e.preventDefault;
    thisContent = this.id;
    jQuery('.post-item').not('.'+thisContent).fadeOut();
    $('.'+thisContent).fadeIn();
});

作为@,最后注意到修改您的选择器。。当您使用click on Anchor时,您需要使用e.preventDefault试试这个

jQuery('.content-btn').click(function(e) {
    e.preventDefault;
    thisContent = this.id;
    jQuery('.post-item').not('.'+thisContent).fadeOut();
    $('.'+thisContent).fadeIn();
});

您有错误吗?有错误吗?有错误吗?有错误吗?有错误吗?