EN
JavaScript - remove all classList items
0 points
In this article, we would like to show you how to remove all items from the element's classList
using JavaScript.
In this example, we remove all the classes from the element
by setting element.className
to the empty string (''
).
xxxxxxxxxx
1
2
<html>
3
<body>
4
<div id="element" class="border shadow">Some content here ...</div>
5
<script>
6
7
var element = document.querySelector('#element');
8
9
element.className = ''; // <--- clears classList
10
11
console.log(element.outerHTML);
12
13
</script>
14
</body>
15
</html>