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 tag, jquery has to look through all the paragraphs to find the one with the 'thisIsMyParagraph' id..
dennis. Pogo wrote:
This is the simplest of ideas, but I'm new to jQuery (I probably shouldn't admit that), and I want to know, when working with the power of the "$" how does one return a reference. I hope I'm saying this correctly. Allow me to illustrate: Let's say one grabs a paragraph with the ID "thisIsMyParagraph" Using CSS traversing, like thus: $("p#thisIsMyParagraph") Yes? With me? Now jQuery provides a whole library to then work with that paragraph. For example, if I wanted to hide the paragraph, go like thus: $ ("p#thisIsMyParagraph").hide(); Correct? Now, HERE'S THE QUESTION. What if I want to call native functions to the DOM object behind the scenes. The obvious way is to go: var element = document.createElement("thisIsMyParagraph"); 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? Just trying to understand. Thanks.