Josh Nathanson wrote:
> > well as many other jQuery newbies?  Specifically, what signifigance 
> > does jQuery's $() being like an array have, and even when 
> you use an 
> > ID selector?
> 
> It is very significant -- in fact you could even say it is 
> one of the most important code-saving aspects of the jQuery library.
> 
> When you do something like $(".myclass") you will get an 
> array of the DOM nodes that match class .myclass.  Now apply 
> a jQuery method like css: 
> $(".myclass").css("color","black").  jQuery knows to loop 
> over the array of DOM nodes and apply that css method to all 
> the DOM nodes in the array.  This saves a ton of coding where 
> you would have to manually loop over the nodes to achieve the 
> same thing.
> 
> This shortcut is such a codesaver, in so many ways, that it 
> is well worth it to always return an array-like object, and 
> then have to use something like .length to determine if the 
> jQuery object is empty.

Thanks for your reply.  

Hmm. I already understood that pretty well.  Maybe I was just expecting to
have a more profound "Aha."

BTW, I'm an old server-side web programmer but new to real-life
client-side/AJAX/browser-based programming so maybe it's just I never had to
feel the pain of the bad ole days of client-side programming that makes me
feel that explanation to be anti-climactic.  

Ah well, guess I should be happy it's easier now, eh?

-- 
-Mike Schinkel
http://www.mikeschinkel.com/blogs/
http://www.welldesignedurls.org
http://atlanta-web.org 

Reply via email to