toggle css class in javascript
snippet in javascript

toggle css class in javascript

user2687

/* var or const followed by its name */.getElementById(/* HTML element ID */);
/* var or const's name */.classList.toggle(/* Name of CSS class */);
// I hope this helps! 

jquery toggle class

user9073

$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );

toggle class javascript

user6021

var menu = document.querySelector('.menu') // Using a class instead, see note below.
menu.classList.toggle('hidden-phone');

toggle js

user3542


function myFunction() {
  var element = document.getElementById("myDIV");

    element.classList.toggle("mystyle");
}