> id is supposed to be unique is it not? My example used the # to refer > to a unique id on the page, therefore *not* an array of objects.
Wrong, it *is* still an array of objects, it's just an array of length 1. Do console.log($('#foo')) and you'll see that it is still an array, and an array with one object in it is not the same as the object itself. > AFAIK all three examples get an element on the page as a *single* (not > an array) object. And that's wrong. The jQuery object is always an array. It's of length 0 for no matches, 1 for a single match, or more for multiple matches. That's by design, so that the chaining things work consistently. This allows you to make chained calls that won't throw an error, regardless of whether or not the selector found anything. > I think it's reasonable (though perhaps not programmatically correct) > to see $('#foo') as the equivalent of document.getElementById('foo'). > If this is not true in jQuery, which it does not appear to be, all I Right, it's not. > am saying is this distinction should be clearly documented. Agreed. This should probably be made clearer. I think the recently discussed post by Simon Willison addresses this really well (under "Doing stuff with them"): http://simonwillison.net/2007/Aug/15/jquery/ --Erik