JavaScript - add, remove, get and check element class name
In this article, we want to show a simple summary of the operations on the classList
property located inside the element. The class list lets to add single class names into elements under JavaScript.
Note:
The element can have only unique class names like Set does.
Operation | Description | |
---|---|---|
1 | add |
With
|
2 | get |
By default Go to below |
3 | set |
When
|
4 | remove |
With
|
5 | replace |
With
|
6 | toggle |
When
In other words, we can say: the When
|
7 | contains |
With
|
8 | clear |
With
|
9 | iterating |
In the example below, we use
|