Although the JavaScript Framework Prototype has a lot of cool functions and features for adding and removing individual CSS classes to and from an element, it doesn't have any function to remove ALL classes.
Therefore I've created a simple little function that when passed an element as a parameter will remove all CSS classes from this element in a single call...
function removeAllCssClasses(el) {
var classArray = $(el).classNames().toArray();
for (var index = 0, len = classArray.size(); index <len; ++index) {
$(el).removeClassName(classArray[index]);
}
}
Don't forgot that as this function uses some of the Prototype magic you will obviously need to import the prototype.js file into any page that you use this function on.
Daniel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Bryant (Director) | Tai-Dev Ltd www.tai-dev.co.uk - IT Consultancy Services Specialising in JEE, Web 2.0 and RDBMS

