Reputation: 10849
Occasionally I come across situations where certain I have to use document.getElementById()
in order to get certain code to work (like w/ Google Maps API for example) for reasons I don't understand. Is there a jQuery method or some relatively easy way to convert a jQuery object to the sort of object returned w/ document.getElementById()
?
Upvotes: 3
Views: 75
Reputation: 16828
Yes you can get the underlying DOM node using
$(myselector)[0]
or
$(myselector).get(0)
In addition to the above:
$(myselector).get()
, without an index, will return an array of DOM nodes.
Upvotes: 1
Reputation: 39889
You can do $("#someDiv").get(0)
which will return the HTMLElement
object (which is the same that is returned by calling document.getElementById()
Upvotes: 2