jQuery:选择给定类的所有元素,特定ID除外 [英] jQuery: select all elements of a given class, except for a particular Id

查看:83
本文介绍了jQuery:选择给定类的所有元素,特定ID除外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能很简单.

除了ID为thisId之外,我想选择给定类thisClass的所有元素.

I want to select all elements of a given class thisClass, except where the id is thisId.

即等同于(其中-/减号表示删除)的东西:

i.e. something equivalent to (where -/minus implies remove):

$(".thisClass"-"#thisId").doAction();

推荐答案

使用 :不选择器 .

$(".thisclass:not(#thisid)").doAction();

如果您有多个ID或选择器,则只需使用逗号定界符,此外:

If you have multiple ids or selectors just use the comma delimiter, in addition:

(".thisclass:not(#thisid,#thatid)").doAction();

这篇关于jQuery:选择给定类的所有元素,特定ID除外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆