[jQuery] Re: Return a reference to the root DOM object

2007-05-11 Thread John Resig
I understand that one way of doing the same thing in jQuery is to reference it thus: var element = $(p#thisIsMyParagraph)[0]; IS THIS CORRECT? Is there a more correct way, or is this the only way? You're spot-on. That is the correct way to get a reference to the original DOM node. --John

[jQuery] Re: Return a reference to the root DOM object

2007-05-11 Thread spinnach
yes, all of what you said is correct.. an alternative way to access a single dom element would be $(p#thisIsMyParagraph).get(0) (both ways to access the dom element are correct).. just one advice, it's much faster to find the element with just the id, without the tag,.. because when writing

[jQuery] Re: Return a reference to the root DOM object

2007-05-11 Thread Dan G. Switzer, II
yes, all of what you said is correct.. an alternative way to access a single dom element would be $(p#thisIsMyParagraph).get(0) (both ways to access the dom element are correct).. just one advice, it's much faster to find the element with just the id, without the tag,.. because when writing the

[jQuery] Re: Return a reference to the root DOM object

2007-05-11 Thread Aaron Heimlich
On 5/11/07, Dan G. Switzer, II [EMAIL PROTECTED] wrote: I haven't really spent any time looking through the parsing engine, but wouldn't it be faster to find elements by ID and then filter by the tag? IIRC, that's what the selector engine does currently (that or something like it). p#myId

[jQuery] Re: Return a reference to the root DOM object

2007-05-11 Thread Aaron Heimlich
On 5/11/07, Aaron Heimlich [EMAIL PROTECTED] wrote: IIRC, that's what the selector engine does currently (that or something like it). p#myId used to take a very long time because it would go through every p and look for one with an id of myId. I'm quite sure that jQuery doesn't do that anymore.

[jQuery] Re: Return a reference to the root DOM object

2007-05-11 Thread Dan G. Switzer, II
I haven't really spent any time looking through the parsing engine, but wouldn't it be faster to find elements by ID and then filter by the tag? IIRC, that's what the selector engine does currently (that or something like it). p#myId used to take a very long time because it would go through

[jQuery] Re: Return a reference to the root DOM object

2007-05-11 Thread Pogo
Thanks, everyone, for the answers. On May 11, 1:47 pm, Dan G. Switzer, II [EMAIL PROTECTED] wrote: I haven't really spent any time looking through the parsing engine, but wouldn't it be faster to find elements by ID and then filter by the tag? IIRC, that's what the selector engine does