Wouldn't your code be faster if you did it without generating a new
jQuery Object for each element you're doing this for. Also, you could
just use the internal jQuery.className.has(el,className) rather than
.is('.'+className) since .is() still needs to regex parse your input
string to determine that you're looking for a className followed by the
actual className test whereas jQuery.className.has(el,className) just
needs to do the className test.$.fn.swapClass = function(c1, c2){
return this.each(function(){
if (jQuery.className.has(this,c1)) {
jQuery.className.remove(this,c1);
jQuery.className.add(this,c2);
} else {
jQuery.className.remove(this,c2);
jQuery.className.add(this,c1);
}
});
}
It's a marginal improvement but one that would be felt on large
projects that use this frequently.-blair Wil Stuckey wrote:
|
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
