Convert jquery element to html element

JavascriptJqueryElement

Javascript Problem Overview


I have a jQuery element but I have to send it to a function that only accepts HTML elements. How can I convert the jQuery element to an HTML element?

Javascript Solutions


Solution 1 - Javascript

Try myJQueryElement.get(0) or myJQueryElement[0]. (get() is most useful when you need negative indices, for example, as described in the documentation for get().)

Solution 2 - Javascript

$("#foo")[0] will get you an HTML element. Using brackets is a tiny bit faster than using .get() but not something you'll likely notice unless you are doing it [millions of times][1].

[1]: http://jsperf.com/jquery-brackets-vs-get "millions of times"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFreesnöwView Question on Stackoverflow
Solution 1 - JavascriptjtbandesView Answer on Stackoverflow
Solution 2 - JavascriptDennisView Answer on Stackoverflow