I wanted to know how to add and remove a class in html elements with javascript
<div>
<ul>
<li class="Active">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
I wanted to know how to add and remove a class in html elements with javascript
<div>
<ul>
<li class="Active">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
Seven the element's class to empty.
// Pega o primeiro li e remove a classe
document.getElementsByName("li")[0].className = "";
If you want to keep some class, reset the class:
document.getElementsByName("li")[0].className = "";
document.getElementsByName("li")[0].className = "classe_que_fica";
I hope I have helped!
Any questions, just leave a comment.