[jQuery] assigning jquery object to a variable?
Hi Howie,
in opposition to Prototype jQuery does not "intrude" into the prototypes
of javascript objects, but gives you back an object that is a wrapper
around the DOM element(s), you want to access.
So you cannot not have both, if you want to use the jQuery
methods(shortcuts) to work with the element, you need the jQuery wrapper
object, if you want to use other javascript methods directly, you need
the Javascript DOM element, which you can get with the get() function.
Otherwise there would have to be a wrapper function for every possible
javascript accessor.
So, it would not really help to differentiate between one node or many
nodes as return value for the $() of jQuery.
@Others: Please correct me, if I'm wrong here, that is just my
understanding of it so far :)
Cheers,
Holger
> -----Original Message-----
> From: discuss-bounces@jquery.com
> [mailto:discuss-bounces@jquery.com] On Behalf Of howie
> Sent: Monday, May 08, 2006 12:00 PM
> To: jQuery Discussion.
> Subject: Re: [jQuery] assigning jquery object to a variable?
>
> Hi Klaus.
>
> thanks for the quick response!
>
> ok. makes sense. will try that.
>
> Element ID's must be unique, so why not return the object if
> querying by ID as there can only be one.
>
> Also, doesn't Javascript assign the object if there is one
> element, but an array if there are more e.g. with form
> fields. Would be nice to follow the convention.
>
> Anyway, great work. When I play with it some more, perhaps
> I'll blog my findings
>
> regards
>
> Howie
>
> On 08/05/06, Klaus Hartl <office@stilbuero.de>