Reputation: 4200
Can I in some way select all input submit elements that are not disabled?
I can easily find all the disabled ones with: http://api.jquery.com/disabled-selector/
$("input.saveitembtn:disabled")
but is there something a'la:
$("input.saveitembtn:NOTdisabled")
My solution until now is to run through them all with jQuerys .each
using .is
to check each one individually:
$("input.saveitembtn").each(function(a){
if( !$(this).is(':disabled') ) {
...
}
});
which I find as total overkill. Is there a simple selector in jQuery?
Upvotes: 22
Views: 33230
Reputation: 206078
Vanilla JavaScript:
const ELS_enabled = document.querySelectorAll("input:not([disabled])");
console.log(ELS_enabled.length); // 2
<input type="text" required placeholder="Required">
<input type="text" required disabled placeholder="Required and disabled">
<input type="text" required placeholder="Required">
Upvotes: 3
Reputation: 22941
Not sure why but the accept answer does not work for me. However this does:
$("input.saveitembtn:not([disabled])");
Upvotes: 13