Jordan Savant // Software Engineer

-- JAVASCRIPT --

// Remove all classes from element
element.className = '';

// Set the class
element.className = 'class_name';

// Remove a single class
var remove_class = 'class_name';
element.className = element.className.replace(' ' + remove_class, '').replace(remove_class, '');

// Append a class
if(element.className.indexOf('class_name') == -1)
{
    element.className += ' class_name';
}

// Get class names
var classes = element.className.split(' ');


-- PROTOTYPE --

// Remove a single class
$('element').removeClassName('class_name');

// Append a class
$('element').addClassName('class_name');

// Get class names
var classes = $('element').classNames();
classes.each(function(c){
    console.log(c);
});