On Dec 3, 12:59 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> That is half correct.
>
> Obj.method1().method2().method3()
>
> method1 return the modified original object, not a brand-new object.
>
> You could do this:
>
> var obj = $('#elementid');
> obj.method1();
> obj.method2();
> obj.method3();
>
> And it would be the same (with the same performance) of:
>
> $('#elementid').method1().method2().method3();
Ahh, that clears it things up.
> Personally, I like chaining because it makes for tighter code. You can also
> do something like this:
>
> $('#elementid').addClass('someclass')
> .children('div')
> .addClass('someclass')
> .end()
> .find('ul')
> .show();
>
> That will find the element, add the class, then find the child divs and add
> the class, then revert to the original element (#elementid) and then find
> any ULs and show them.
>
Yeah, I can see how that makes the code a lot more compact. Thanks for
the great response.