Changing a Single Attribute-Property in jQuery
It is important not to confuse properties and attributes of elements. When creating a DOM tree, attributes are translated into the corresponding DOM properties of elements. Their names do not always match, as do their values.
Some properties may also not have attributes corresponding to them, for them you need to use the prop method, which takes the property name as the first parameter, and true or false as the second.
If you set true, the property will be set, and if false, it will be removed.
Let's look at the following example. Let's say we have an input:
<input type="text" id="test">
Let's set the input attribute to disabled:
$('#test').prop('disabled', true);
HTML the code will look like this:
<input type="text" id="test" disabled>
Now, on the contrary, let's remove disabled:
$('#test').prop('disabled', false);
HTML the code will look like this:
<input type="text" id="test">