How can I remove the "disabled" attribute from an HTML input using javascript?
<input id="edit" disabled>
at onClick I want my input tag to not consist of "disabled" attribute.
This question is related to
javascript
input
attributes
method 1 <input type="text" onclick="this.disabled=false;" disabled>
<hr>
method 2 <input type="text" onclick="this.removeAttribute('disabled');" disabled>
<hr>
method 3 <input type="text" onclick="this.removeAttribute('readonly');" readonly>
code of the previous answers don't seem to work in inline mode, but there is a workaround: method 3.
To set the disabled
to false using the name
property of the input:
document.myForm.myInputName.disabled = false;
Best answer is just removeAttribute
element.removeAttribute("disabled");
Why not just remove that attribute?
elem.removeAttribute('disabled')
elem.removeAttr('disabled')
Source: Stackoverflow.com