I've just noticed, that the jQuery text(...)
method only sets the content of a TEXTAREA
, if if has not been updated manually. For example (also on jsFiddle):
$('#myButton').click(function() {
$('#myText').text(Date.now);
});
<textarea id="myText"></textarea>
<button id="myButton">Go!</button>
<script src="//code.jquery.com/jquery-2.1.0.js"></script>
Now when I click on Go!, the content of the TEXTAREA
gets updated with the current timestamp. I also can do it multiple times. Working. But if I manually change the text (e.g. by deleting or adding a character), it stops working.
I also tried out the val(...)
method. It works as expected, regardless of manual changes on the text field.
How to get jQuery.text(...)
working after manual changes?