Monday, April 6, 2009

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




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



  1. Short and usefull. Thanks

    This commenting method REALLY sucks...

  2. Now after couple of times when I was trying to comment your post(FINALLY!) I have to say that this commenting method REALLY REALLY SUCKS...

    If You want any coments You'd better change it to something NORMAL. I had to try 4 times before posting my previous comment and normal people aren't so pacient.


  3. Thanks a lot, it helped me :)

  4. How do you go the other way around? I have a DOM pointer and I want to use jquery functions on it.

  5. I need to be able to use jquery functions on a DOM pointer/object too.

  6. @mslocum and @Daniel: That's easy! Just wrap it in $() -- for instance, say, you have a DOM object created like this:

    domObject = document.getElementById('mydiv');

    you can turn it into a jQuery object by going like this: