nth-child is very fast. Probably faster than the each method.
-- Yehuda
On 2/15/07, Angelo Sozzi <[EMAIL PROTECTED]> wrote:
Just a minor (nice to know) question:
When stripping multiple tables or lists on a single page
$(.stripMe li:even).addClass('alt');
won't work as it itterates over all the li element regardless of the table
they are in. So I went for:
$('.stripMe').each(function(i) {$("li:odd", this).addClass('alt'); });
which seems a bit slow for the amount of list I used. Then I found the
zebra
tutorial with a new workaround:
$('.stripMe li:nth-child(even)').addClass('alt');
Besides the fact that it is nicer code, does anyone know how
li:nth-child(even) works? Is it essentially the same as using .each(... or
what? and which one is faster?
(yes, if necessary I'll check it out and post results but maybe someone
knows already)
Regards
--
View this message in context:
http://www.nabble.com/Table-striping%2C-speed-question-tf3235049.html#a8989876
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
--
Yehuda Katz
Web Developer | Wycats Designs
(ph) 718.877.1325
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/