Just remove the space:
$("textarea#myTextArea").val(text);
You are currently trying to select an element with the identifier myTextArea , which is a descendant of the textarea element
As Jared Farrish says in the comments, removing an item type would be more efficient:
$("#myTextArea").val(text);
If your document is valid, each identifier will be used only once, so this is still correct.
Clive
source share