Freesnöw
Freesnöw

Reputation: 32143

Convert jquery element to html element

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?

Upvotes: 81

Views: 83846

Answers (2)

jtbandes
jtbandes

Reputation: 118671

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().)

Upvotes: 126

Dennis
Dennis

Reputation: 32598

$("#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.

Upvotes: 33

Related Questions