jquery selector for all checked checkboxes that ar

2019-04-03 14:42发布

问题:

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

回答1:

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


回答2:

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:

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

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

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

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



回答3:

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

Here's a fiddle



回答4:

You can use this selector..

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

Check This FIDDLE



回答5:

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