var textarea = document.getElementById("id");
var text = textarea.innerHTML;
My problem is that "text" always remains the value the textarea started out with. Not what was typed in.
Page loads with "sample text"
Change text to "other"
Call the above code
Value of the var text is "sample text"
Research suggests that entering text, changes some other type of object. But how do I access that one?
The only thing resembling a workaround, at best, so far. Seems to be recording inputs with on change events. But that seems to be absurdly over complicated. When I just need one single snapshot once, on explicit request.
2
Answers
Use rather
value
:Instead of
innerHTML
you need to use the value. Here’s a snippet where oninput
event we display the newest value at the top of a div that acts as a change log for the purpose of the test: