I have an iframe that contains a textarea, like so:
's content:var text1 = document.getElementById('myTextArea').value; // plain JavaScript
var text2 = $("#myTextArea").val(); // jQuery
':document.getElementById('myTextArea').value = 'new value'; // plain JavaScript
$("#myTextArea").val('new value'); // jQuery
See DEMO JSFiddle here.
.html()
or .innerHTML
!jQuery's .html()
and JavaScript's .innerHTML
should not be used, as they do not pick up changes to the textarea's text.
When the user types on the textarea, the .html()
won't return the typed value, but the original one -- check demo fiddle above for an example.