Hi Evert,

'.someclass' is a slow selector as it has to check every single
element on the page to see if it matches class="someclass". Limiting
the search closer to the desired elements will speed up the selection
hugely. For example, choose the closest common ancestor that all
potential target elements share and that has an id (say,
#somecontainer) and also specify the type of element that the target
will be if possible (in this case, a div). Your improved code would
look like this:

// find all divs with class 'someclass' that are somewhere within
// (descendant of) an element with id 'somecontainer':

$('#somecontainer div.someclass').removeClass['someclass');

Please let us know if your code still seems slow in IE7 after this.

Joel Birch.

Reply via email to