Get JavaScript Object From jQuery

Today I searched Get JavaScript Object From jQuery trying to fix old code. I wanted to fix it by using some jQuery selectors but I still wanted to use most of the old JavaScript code. I initial passes up the jQuery page on the .get() method but then came back to it and was exactly what I needed.

Retrieve the DOM elements matched by the jQuery object.

So it was simple to get the first element of the selector with the get object.

var javascriptVar = $("#jQuerySelector").get(0);

This worked perfectly and allowed all of the old javascirpt to function with the more advanced selector than the good old document.getElementById()

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Go back to top