未禁用的所有选中复选框的 jquery 选择器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12358231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:36:27  来源:igfitidea点击:

jquery selector for all checked checkboxes that are not disabled

jqueryjquery-selectorscheckbox

提问by forkie

how can I find all checkboxes, that are checked and not disabled?

如何找到所有已选中但未禁用的复选框?

采纳答案by Hoffmann

$('input[type="checkbox"]').filter(function() {
return !this.disabled && this.checked;
})

回答by Eric

Like so:

像这样:

$("input[type='checkbox']:checked").not(":disabled")...

This finds fields that are inputs, with type checkbox, which are checked, and not disabled. If this does not work, you should use an attribute check:

这将查找inputs、类型checkbox为已选中且未禁用的字段。如果这不起作用,您应该使用属性检查:

$("input[type='checkbox']:checked").not("[disabled]")...

Or, as @lonesomeday astutely pointed out, you can combine it into one selector:

或者,正如@lonesomeday 敏锐地指出的那样,您可以将其合并为一个选择器:

$("input[type='checkbox']:checked:not(:disabled)")...

I've put together a proof-of-concept in this fiddle.

在这个 fiddle 中整理了一个概念验证。

回答by VVV

$('input[type="checkbox"]:checked').not(":disabled");

Here's a fiddle

这是一把小提琴

回答by Sushanth --

You can use this selector..

您可以使用此选择器..

?$('input[type=checkbox]:checked:not(:disabled)')?

Check This FIDDLE

检查这个小提琴

回答by Erico Chan

how about $("input[type='checkbox']:checked:enabled")?

怎么样$("input[type='checkbox']:checked:enabled")