For my needs I use
$('#form :input').each( function(i) {
if ( !$(this).hasClass('donot') ) {
$(this).attr('disabled', 'disabled');
}
});
is there a better way to not use the if condition to check if the input has the class 'donot' ?
Thanks for your help...
Chris
$('#form input:not(.donot)').each( function(i) {
$(this).attr('disabled', 'disabled');
});
And there you go :-D
Docs for :not()
selector
Or you can also do:
$('#form input').not('.donot').each( function(i) {
$(this).attr('disabled', 'disabled');
});
Docs for .not()
Try this and also you don't even need each loop to do this.
$('#form input:not(.donot)').attr('disabled', 'disabled');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With