$('div.myclass');
Perfect - made a difference already. I should have thought of that! :-)
Thanks a lot...
Matthew
_____
From: Aaron Heimlich [mailto:[EMAIL PROTECTED]
Sent: Friday, 17 November 2006 10:29 a.m.
To: [EMAIL PROTECTED]; jQuery Discussion.
Subject: Re: [jQuery] alternative to $('.myclass')
$('.myclass') is, as you've noticed, pretty slow because it has to search
through the *entire* page looking for element with a class of "myclass".
There are a couple things you can do:
If you know that all of the elements you want are, say, <div>'s, then
$('div.myclass');
is going to be a lot faster
If you know that all of the element you want are children of a particular
element, then you could do
$('.myclass', contextElement);
which will restrict jQuery's search to contextElement (instead of the entire
page)
On 11/16/06, Matthew Delmarter <[EMAIL PROTECTED]> wrote:
Hi all,
I am using the $('.myclass') approach quite a lot, but am finding it is
slowing down my pages when used a lot. Is there an alternative method I can
use in jQuery that is faster? What about Xpath - any tips?
Thanks for you help...
Matthew
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/