how to add multiple css class in javascript code example
Example 1: add multiple class list at once in js
elem.classList.add("first");
elem.classList.add("second");
elem.classList.add("third");
is equal to :
elem.classList.add("first","second","third");
Example 2: css multiple classes
//HTML Code
<div class = 'firstClass secondClass'></div>
//CSS Code
.firstClass.secondClass {
}
Example 3: css change multiple classes
.objectOne, .objectTwo { /* We will now both be changed */
margin: 0 auto;
}
Example 4: css assign multiple classes to one element
To specify multiple classes, separate the class names with a space,
e.g. <span class="classA classB">.
This allows you to combine several CSS classes for one HTML element.
Example 5: css multiple classes
<div class="a-class another-class"></div>