>> It is a little faster to remove classes only on the rows that are
>> highlighted:
>> 
>>    $("#tableid tr.highlight").removeClass("highlight");

> Is it really that way? I wondered about that several times what
> is faster - the additional lookup for the class name or the brute
> force removal for all rows...

I haven't timed it, but I'm almost certain. John's new 1.1 changes for the
selectors use a cached regexp to find classes as it scans the tree, which is
fast. In contrast, the removeClass code splits the class string for each
element into an array, looks for a matching class to be removed, and then
rejoins it to a new string. By selecting only the highlight elements, you
avoid doing the removeClass code so many times. It probably doesn't matter
too much in most pages, but since were talking about tables there could be a
couple of hundred rows...



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

Reply via email to