$("#myElement) returns jQuery object and $("#myElement")[0] returns DHTML object.
Here is a sample on how to access alt attribute jQuery $("#myElement").attr("alt") vs DHTML $("#myElement")[0].alt Both code return the same value. Correct me if i am wrong, I think the DHTML version is faster than the jQuery one. On Jul 21, 8:07 am, nyte999 <zend...@gmail.com> wrote: > Going through the tutorials on this website and others, I've found > some syntax that I don't understand and is never explained. Usually > wrapped sets look like this: > > $(#myElement) > > But once in a while they look like this > > $(#myElement)[0] > > Here are a few examples of it in use: > > $("div").index($("div#myDiv")[0]); > $("#myImage")[0].alt; > > I don't get it. The sample code is NEVER trying to find the first > element of an array. From my POV this format seems completely random > and unnecessary, yet the jQuery code will NOT work if the "[0]" is > removed. I know it's something glaringly obvious and I'll feel stupid > when I get the answer, but my god, I just can't figure out the pattern > here. Please help.