gpt4 book ai didi

Jquery 选择除一个类之外的所有类

转载 作者:行者123 更新时间:2023-11-30 23:57:12 24 4
gpt4 key购买 nike

我想做这样的事情:

$('.anwer_labels').click(function() {
$(this).toggleClass('active');
$('.anwer_labels').removeClass('active');
// $(this).addClass('active').siblings().removeClass('active');;
// $(this).removeClass('active');
})

在这一行中,我想添加一个异常(exception),这样我就不会包含 $(this):

$('.anwer_labels').removeClass('active'); //some code here to not add $(this)

这可以做到吗?

最佳答案

not()会做的。

$('.anwer_labels').not(this).removeClass('active');

关于Jquery 选择除一个类之外的所有类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16331888/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com