> I second the request for a good understanding of what the JQuery object is.


The jQuery object is just a JavaScript object (like Date or Array).
It encapsulates zero or more DOM elements and lets you manipulate
those elements using the jQuery API.

    var jq = $('.myClass');

The statement above selects all elements that have a class of
'myClass' and wraps them in an object - the jQuery object.  Once those
elements are wrapped in a jQuery object you can use the jQuery API to
do all kinds of things with them.  Like show them all:

    jq.show();

or add a click event handler to all of them:

    jq.click(function() { alert ('I was clicked'); });

or access each of the selected DOM elements:

    jq.each(function(i) {
        // 'this' is the DOM element inside the 'each' method
        this.innerHTML = 'my index is ' + i;
    });

That's really the nuts and bolts of it.  jQuery lets you easily select
elements in the DOM and do something with them.  It's selection
capabilities are very powerful and very fast.  And it's API is quite
extensive.

You'll also find that most of the functions in the jQuery API return
the jQuery object on which they operate.  This means they are
chainable and this is great when you want to do more than one thing
with the selected elements.  The examples above could be combined into
a single statement like this:

    $('.myClass').show().click(function() {
        alert ('I was clicked');
    }).each(function(i) {
        this.innerHTML = 'my index is ' + i;
    });

Mike

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to