/ Published in: jQuery
                    
                                        
I notice a lot of addClass/removeClass.. thought maybe I'd post an example on how to simplify that....
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/*
** jquery.replaceClass.js -- jQuery "plugin", helps classname manip.
** Copyright (c) 2007 Francois Lafortune (quickredfox.at)
** Licensed under MIT
**
*/
jQuery.fn.replaceClass = function(toReplace,replaceWith){
return $(this).each(function(){
return $(this).removeClass(toReplace).addClass(replaceWith);
});
}
// Of course, you'd rarely ever save this file like this, what you wanna do
// is create a little extensions file for all your tiny little jQuery
// quirks and re-use that...
jQuery.extend(jQuery.fn,{
replaceClass = function(){//code...},
otherHelper = function(){ //... }
// etc ...
})
Comments
 Subscribe to comments
                    Subscribe to comments
                
                