W3.JS Add Class
Add classes to HTML elements
Add a class:
w3.addClass(selector,'class')
Add multiple classes:
w3.addClass(selector,'class1 class2 class3...')
Add Class by Id
Add the "marked" class to an element with id="London":
Add Class by Tag
Add the "marked" class to all <h2> elements:
Add Class by Class
Add the "marked" class to an elements with class="London":
Add Multiple Classes
To add multiple classes to an element, separate each class with a space.
Add both "class1" and "class2" to an element with id="London":
Example
<button onclick="w3.addClass('#London','class1 class2')">Add
Classes</button>