ClassName przełącz JS
document.getElementById('myButton').onclick = function() {
this.classList.toggle('active');
}
Yucky Yak
document.getElementById('myButton').onclick = function() {
this.classList.toggle('active');
}
$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );
$('.click-class').click(function() {
$('.class-toggle').toggle();
$('.class-toggle').toggleClass('add-class');
})
var menu = document.querySelector('.menu') // Using a class instead, see note below.
menu.classList.toggle('hidden-phone');
element.classList.toggle('class');
document.getElementById('myButton').onclick = function() {
var className = ' ' + myButton.className + ' ';
if ( ~className.indexOf(' active ') ) {
this.className = className.replace(' active ', ' ');
} else {
this.className += ' active';
}
}