Would caching the jQuery object a help too? Sometimes you just can't
keep the chain.

e.g. var jqObj = $("#abc");

On 10/8/06, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> On Oct 7, 2006, at 3:39 PM, George Adamson wrote:
>
> > An easy performance booster is to use the second param in $() to set a
> > context for the search. Eg: $("DIV.myClass", myParentElement).
> > Perhaps this
> > is what you meant when you mentioned 'getting a parent element' ?
> >
> > Chaining methods is helpful so you can avoid re-querying. If you
> > need to put
> > other code in betwen method calls then reusing the same JQuery
> > object by
> > putting it into a variable beforehand is worth while to save
> > requerying.
> >
> > If you're going to do several queries inside the same parent element
> > (s) then
> > a combination of the above will be a big help.
>
> Those sound like good suggestions to me, though I'm no expert.
>
> Something I try to keep in mind is the relative speed of different
> types of queries. This has been mentioned on the list before, but in
> case you didn't see it, references to IDs are fastest, followed by
> elements, and then classes. At least, that's how I've understood
> previous discussions of the topic. So:
> a.  $('#my-id') is faster than $('div#my-id'), and
> b. $('div.my-class') is faster than $('.my-class')
>
> Hop that helps.
>
> Karl
> _______________________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

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

Reply via email to