This needs to be post somewhere on the jQuery site and getjquery.org very prominently. Excellent post Mike (damn, man you're on a roll!).
On 12/12/06, Mike Alsup <[EMAIL PROTECTED]> wrote:
> jquery objects - chaining - closures > > That's the stuffs I wanna to master in order to claim that I really feel > confident with jquery. The key here is that you really do need to understand javascript. jQuery is a javascript library. It uses objects and closures. It manages the dom and events. It provides effects and ajax functionality. But all of this is possible without jQuery. The beauty and power of jQuery is that it makes these things easy. But you must still understand what they are and how they work. You need to understand scoping rules, scope chains, and closures. You need to understand the DOM. You need to understand these things not because you're using jQuery but because you're programming in javascript. And if you feel like you're already at that level then dig right in and look at the jQuery source code. It is a great example of how to write good javascript and it's well-documented too. Don't treat the source like a black-box. Regarding the jQuery object. It's just an object. Like Date or Array. It encapsulates zero or more DOM nodes and lets you manipulate those nodes using the jQuery API. $ is the shorthand notation for the jQuery object. Regarding chaining - Yes, jQuery's chaining is great. But jQuery didn't invent chaining. It's just an OO programming concept that's been around for ages. You'll find that most jQuery methods return 'this' which means they return the jQuery object. That lets you keep calling more functions like this: $('.myClass').func1().func2().func3(). Without chaining you'd have to write: var jq = $('.myClass'); jq.func1(); jq.func2(); jq.func3(); That's the whole idea behind chaining. The documentation is quite good so if you want to know if a method is chainable, just look it up in the docs. If it returns a jQuery object then it's chainable. Sorry to ramble on so long. Good luck! _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
-- Aaron Heimlich Web Developer [EMAIL PROTECTED] http://aheimlich.freepgs.com
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/