Thank you Mike. That makes sense!
But what is the purpose of .get() then? What could I do with an "actual JavaScript Array object" which I couldn't do the way you demonstrate? Harvey On Dec 2, 11:48 am, Michael Geary <m...@mg.to> wrote: > The jQuery object - the return value from $(whatever) - is an array-like > object with .length and [0] etc. properties. You don't need to call .get() > on it unless you need an actual JavaScript Array object, which is rare. > > The *elements* of the jQuery object - or the elements of the Array that > .get() returns, are plain HTML elements - DOM nodes. They are not jQuery > objects themselves. They have DOM methods and properties, not jQuery > methods. > > You can always wrap a DOM node in a jQuery object with $(theDomNode). > > You can use a for loop just like the one you have, directly on a jQuery > object without calling .get(). Or you can use jQuery's .each() method, which > is often cleaner. One way to write your loop would be like this: > > $('.resizable').each( function( i, box ) { > console.log( box.id + ': left=' + $(box).css('left') ); > }); > > In this code, 'box' is the same as 'boxes[i]' in your for loop. Note the > difference between box.id - referencing a property of the DOM node directly > - and $(box).css() - wrapping the DOM node inside another jQuery object and > then calling a jQuery method on that object. > > -Mike >