Reputation: 1004
Im creating a simple HTML form that lets you click on a text and set the value in an input field.
The problem is when I manually delete the value, I cant click and set a new value.
I created a JSFiddle: http://jsfiddle.net/s4faujvo/
document.getElementById("pnr").setAttribute("value", this.textContent);
(Click on 2222 and 9999 to see it change, delete/blank the value manually, click on 222 or 999 again)
Am I doing something wrong here?
Upvotes: 0
Views: 81
Reputation: 6016
Value is a property, not an attribute. To access, use:
document.getElementById("pnr").value=this.textContent;
.
Upvotes: 2