jQuery - 如何选择所有复选框除了一个特定的? [英] jQuery - How to select all checkboxes EXCEPT a specific one?

查看:215
本文介绍了jQuery - 如何选择所有复选框除了一个特定的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jQuery选择器,看起来像这样...

I have a jQuery selector that looks like this ...

$("input:checkbox").click(function(event) {
  // DO STUFF HERE
}

工作得很好,直到我被要求添加另一个与原始复选框无关的复选框。如何为所有复选框创建一个选择器(除了一个)?

Everything was working well until I was asked to add another checkbox that has nothing to do with the original checkboxes. How do I create a selector for all checkboxes except for one? Thank you.

推荐答案

$('input:checkbox:not("#thatCheckboxId")').click(function(event) {
  // DO STUFF HERE
}

只要将相关复选框设置为唯一 id =

Just give the checkbox in question a unique id=""

这篇关于jQuery - 如何选择所有复选框除了一个特定的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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