Sign in


Add a classname to the selected elements' class attribute, while preserving any other classnames they may have.


neon.addClass(string classname)


The name of the classname to add.


This method should be executed on a selection of elements. Please see the .select() method.

Return value

This method is chainable. It returns a copy of the Neon object on which it was called.


This method allows you to add a classname to a number of elements, while preserving any other classnames they may have.

An element on a page may have a "class" attribute containing any number of classnames, separated by whitespace. You could set this attribute by calling .setAttribute(), but this overwrites the entire attribute, which would remove all existing classnames from your elements. .addClass() allows you to add an additional classname.

It's safe to call this on elements which already have the given classname. The classname won't be duplicated (though the order of classnames may be changed).