Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

toogle class add and remove class

<button onclick="myFunction()">Try it</button>

<div id="myDIV" class="mystyle">
This is a DIV element.
</div>

<script>
function myFunction() {
   var element = document.getElementById("myDIV");
   //	element.classList.toggle("mystyle2");
    element.classList.remove("mystyle2");
    element.classList.add("mystyle");
};
</script>
 
PREVIOUS NEXT
Tagged: #toogle #class #add #remove #class
ADD COMMENT
Topic
Name
7+5 =