1// html <div class="parentElm" id="addActive"></div>
2
3// js
4function toggleClass(){
5 // get the properties of an element
6 var element = document.getElementById("addActive");
7
8// check if the element have class list
9 if (element.classList) {
10 // add active class if true
11 element.classList.toggle("active");
12 } else {
13 var classes = element.className.split(" ");
14 var i = classes.indexOf("active");
15 }
16 }