Re: assigning jquery object to a variable?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: assigning jquery object to a variable?

Rode, Holger (daemons point)
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: [hidden email]
> [mailto:[hidden email]] 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 <[hidden email]> wrote:
> > Hello Howie,
> >
> > of course you can, but you mustn't mix DOM and jQuery:
> >
> > var myElement = $("#myElementId").get(0); myElement.style.display =
> > "none";
> >
> > or:
> >
> > var myQuery = $("#myElementId");
> > myQuery.css("display", "none");
> >
> >
> > Regards, Klaus
> >
> >
> >
> > howie schrieb:
> > > jQuery looks nice, but seems to be missing the basics.
> Perhaps not.
> > > Perhaps is just lacking documentation.
> > >
> > > Why can't i do this?
> > >
> > > var myElement = $("#myElementId");
> > > myElement.style.display = "none";
> > >
> > > yet i can do :
> > >
> > > $("#myElementId").css("display" "none");
> > >
> > > I want to assign the query object to avariable to perform
> multiple
> > > attribute updates  without re-querying (or chaining).
> > >
> > > Am I missing something? Or am I gonig t have to go back
> to prototype ?
> > >
> > > thanks
> > >
> > > --
> > > howie
> > >
> > > _______________________________________________
> > > jQuery mailing list
> > > [hidden email]
> > > http://jquery.com/discuss/
> > >
> >
> > --
> > Klaus
> >
> > _______________________________________________
> > jQuery mailing list
> > [hidden email]
> > http://jquery.com/discuss/
> >
>
>
> --
> howie
> _______________________
>
> http://www.microbubble.net
>
> _______________________________________________
> jQuery mailing list
> [hidden email]
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
[hidden email]
http://jquery.com/discuss/