I\'m using this selector
$(\"textarea #myTextArea\").val(text);
and it\'s not working. If I remove the ID and use the class it\'s working. Why isn\'t jquery able t
Because of the space. With the space it says the #myTextArea
within a textarea
.
$("textarea#myTextArea").val(text);
Just remove the space:
$("textarea#myTextArea").val(text);
At the moment you're trying to select an element with ID myTextArea
that is a descendant element of a textarea
As Jared Farrish mentions in the comments removing the element type would be more efficient:
$("#myTextArea").val(text);
If your document is valid then every ID will only used be once so this is still correct.