Alex Alex - 4 months ago 8
jQuery Question

jQuery object to Javascript object

if I have a textarea like

var txtarea = $('textarea');
, how can I set the value to it using the javascript property
value
, and not jQuery's
val()
?

I think I need to convert
txtarea
to a javascript object, but how?

Answer

You can use the dereferencing operator, or the .get() method to "Retrieve the DOM elements matched by the jQuery object."

Examples:

txtArea[0].value = "something";

or:

txtArea.get(0).value = "something";