how to toggle class names on click code example
Example 1: jquery toggle class
$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );
Example 2: 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';
}
}