This should be really simple but I can’t get it to work, how do I disable and add a class to an input? Let’s say I’ve got an input field with id = name, this is how far I got,
$("input#name").attr("disabled");
What am I doing wrong here? Any help would be greatly appreciated, thanks in advance!
You need to give
.attr()a second parameter (the value to set, otherwise it gets the value),truein this case ("disabled"works too, but a boolean is desirable for a few reasons here):.addClass()then adds that class to the element.