Saturday, April 10, 2010

Convert jQuery object to DOM object

jQuery object is a wrap of the DOM object, but itself is not a DOM object. If you want to get the DOM object from the jQuery object, you should use get() method.

For example, if the jQuery object includes only one DOM object, you can use

$("div").get(0)

or

$("div")[0]

However, if you have multiple DOM objects, you can use

$("div").get()

No comments: