JQuery methods and DOM properties

Posted by Bob Smith on Stack Overflow See other posts from Stack Overflow or by Bob Smith
Published on 2009-02-17T16:04:03Z Indexed on 2010/06/14 14:42 UTC
Read the original article Hit count: 293

Filed under:
|
|

I am confused as to when I can use the DOM properties and when I could use the Jquery methods on a Jquery object. Say, I use a selector

var $elemSel = $('#myDiv').find('[id *= \'select\']')

At this point, $elemSel is a jquery object which I understand to be a wrapper around the array of DOM elements. I could get a reference to the DOM elements by iterating through the $elemSel object/array (Correct?)

My questions: 1. Is there a way to convert this $elemSel into a non JQuery regular array of DOM elements? 2. Can I combine DOM properties and JQuery methods at the same time (something like this)

$elemSel.children('td').nodeName

(nodeName is DOM related, children is JQuery related)

EDIT: What's wrong with this?

$elemSel.get(0).is(':checked')

EDIT 2:

Thanks for the responses. I understand now that I can use the get(0) to get a DOM element. Additional questions:

  1. How would I convert a DOM element to a JQuery object?

  2. If I assign "this" to a variable, is that new var DOM or JQuery? If it's JQuery, how can I convert this to a DOM element? (Since I can't use get(0))

    var $elemTd = $(this);

  3. When I do a assignment like the one above, I have seen some code samples not include the $ sign for the variable name. Why?

  4. And as for my original question, can I combine the DOM properties and JQuery functions at the same time on a JQuery object?

    $elemSel.children('td').nodeName

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery