After passing a string "selector" into the jQuery function:
$('#onenode')
An array of jQuery object's is returned.
One of the methods of these object's is "html", which is why:
$('#onenode').html('hello!');
Works.
However...
This:
$('.somenodes')
Returns an array of jQuery objects, each of the objects in this array has the method "html".
So how does:
$('.somenodes').html('hello');
Work? The "html" method must be a method of the Array Object that is returned.
I assume therefore that the "html" method of the Array Object looks similar to this:
html: function(value) {
for(var i=0; i<this.length; i+=1) {
this[i].html(value);
}
}
These are all assumptions, I'm pretty much guessing.
I am attempting to create my own small library that uses "selectors", but I am struggling with this part. I know that this is probably incorrect -- could someone explain how jQuery really does it?