I have this in order to replace attribute disabled with readonly and I want to know if it is possible to not do that for some classes. I want to add something like “if the input does not have class x do action”
$('input[type=text][disabled="disabled"]').removeAttr("disabled").attr("readonly", true);
You can use the
notmethod to exclude elements from the matched set:Alternatively, you could use the
:notpseudo-selector, but as the documentation states, the.notmethod is better “in most cases”.As a side note, you should probably be using the
propmethod rather thanattr, since bothdisabledandreadonlyare DOM properties.