var a = $(...);
var b = a.length;
a.XXX();
var c = a.get(0);

Now, 'a' is a "jQuery object" that contains all of the elements that matched
the selector. 'b' is the number of elements found. The third line is calling
a jQuery function or plugin on the jQuery object that is wrapping the
selected elements. 'c' is the DOM node for the first selected element. To
call a jQuery function or plugin, use 'a', to access DOM properties of the
first element, use 'c'. To access DOM properties of all of the elements that
are wrapped by the jQuery object, use each().

The [n] syntax is just a shortcut for .get(n):
http://docs.jquery.com/Core#get.28_num_.29

Does that help any?

--Erik

On 8/14/07, pd <[EMAIL PROTECTED]> wrote:
>
>
> Hi All
>
> I've been hacking with jQuery on and off lately and I've now hit the
> annoying problem of not being able to access simple DOM 0 properties
> unless, apparently, using either of the following syntaxes:
>
> $('#foo')[0]
>
> $('#foo').get(0)
>
> Eventually after scratching my head each time, I've found this syntax
> answer again. However is this documented? I really find the jQuery
> documentation very handy but I do not remember seeing this crucial
> information within it.
>
> It seems from searching this group, I'm not the only person who
> perceives jQuery methods to provide additional functionality above
> JavaScript, but to still allow access to the simple properties we are
> all familiar with. If this is not the case, and it doesn't seem to be,
> these and other syntax 'shortcuts' really should be documented and
> very obviously at that, shouldn't they?
>
> I can access the wiki and I'm happy to add this information though I
> am not convinced I have a complete 'handle' on it.
>
> pd
>
>

Reply via email to