I have a form and a textarea field in it. I need to make it editable, and I don't know how.
<textarea id="note" class="input" type="text" name="note">Suggest changes</textarea>
When I inspect elements, its readonly attribute is already false, but it won't let me change anything.
I've tried:
document.getElementsByTagName("textarea")[0].readonly = false;
$("#note").prop('readonly', false);
$("#note").removeAttr('readonly');
None of those help.
I have a form and a textarea field in it. I need to make it editable, and I don't know how.
<textarea id="note" class="input" type="text" name="note">Suggest changes</textarea>
When I inspect elements, its readonly attribute is already false, but it won't let me change anything.
I've tried:
document.getElementsByTagName("textarea")[0].readonly = false;
$("#note").prop('readonly', false);
$("#note").removeAttr('readonly');
None of those help.
Share Improve this question asked Dec 5, 2014 at 9:33 DR_DR_ 1741 gold badge2 silver badges14 bronze badges 4 |5 Answers
Reset to default 5The problem is here
document.getElementsByTagName("textarea")[0].readonly = false;
It should be
document.getElementsByTagName("textarea")[0].readOnly = "false";
Or also in your case
document.getElementById("note").readOnly = "false";
Try
$("#note").attr("readonly", false);
I see, the element.removeAttribute('readonly')
works, but I tried only firefox yet.
I had the same problem and solved it with this:
document.getElementById("note").removeAttribute('readonly')
The problem really is the use of the wrong case, readonly
should be written in camel case i.e 'readOnly', so this should work.
document.getElementsByTagName("textarea")[0].readOnly = false;
https://www.w3schools.com/jsref/prop_textarea_readonly.asp
disabled
attribute? – u_mulder Commented Dec 5, 2014 at 9:34$('#note').attr('readonly',false);
– Aditya Commented Dec 5, 2014 at 9:37disabled
. Because by default a<textarea>
is editable. – azhpo Commented Dec 5, 2014 at 9:38