class method Element.addClassName

View source on GitHub →

Element.addClassName(element, className) → Element
  • className (String) – The class name to add.

Adds the given CSS class to element.


Assuming this HTML:

<div id="mutsu" class="apple fruit"></div>


// -> 'apple fruit'
// -> 'apple fruit food'

This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.