toggle javasc code example
Example 1: classname toggle js
document.getElementById('myButton').onclick = function() {
var className = ' ' + myButton.className + ' ';
if ( ~className.indexOf(' active ') ) {
this.className = className.replace(' active ', ' ');
} else {
this.className += ' active';
}
}
Example 2: how to change class by is in js by toggle
<button class="" id="changeicon">
<i id="slideshow" class="fas fa-hamburger"></i>
</button>
$("#changeicon").click(function() {
$("#slideshow").toggleClass("fa-times");
});