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.

Reply via email to