how can I find all checkboxes, that are checked and not disabled?
如何找到所有已选中且未禁用的复选框?
5 个解决方案
#1
5
$('input[type="checkbox"]').filter(function() {
return !this.disabled && this.checked;
})
#2
29
Like so:
$("input[type='checkbox']:checked").not(":disabled")...
This finds fields that are input
s, with type checkbox
, which are checked, and not disabled. If this does not work, you should use an attribute check:
这将查找输入的字段,其类型为复选框,已选中且未禁用。如果这不起作用,您应该使用属性检查:
$("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.
我在这个小提琴中整理了一个概念验证。
#4
3
You can use this selector..
你可以使用这个选择器..
$('input[type=checkbox]:checked:not(:disabled)')
Check This FIDDLE
检查这个FIDDLE
#5
1
how about $("input[type='checkbox']:checked:enabled")
?
怎么样$(“input [type ='checkbox']:选中:启用”)?
#1
5
$('input[type="checkbox"]').filter(function() {
return !this.disabled && this.checked;
})
#2
29
Like so:
$("input[type='checkbox']:checked").not(":disabled")...
This finds fields that are input
s, with type checkbox
, which are checked, and not disabled. If this does not work, you should use an attribute check:
这将查找输入的字段,其类型为复选框,已选中且未禁用。如果这不起作用,您应该使用属性检查:
$("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.
我在这个小提琴中整理了一个概念验证。
#3
#4
3
You can use this selector..
你可以使用这个选择器..
$('input[type=checkbox]:checked:not(:disabled)')
Check This FIDDLE
检查这个FIDDLE
#5
1
how about $("input[type='checkbox']:checked:enabled")
?
怎么样$(“input [type ='checkbox']:选中:启用”)?