onclick toggle class code example
Example 1: toggle class javascript and jquery
$('.click-class').click(function() {
$('.class-toggle').toggle();
$('.class-toggle').toggleClass('add-class');
})
Example 2: jquery toggle class
$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );
Example 3: toggle class javascript
var menu = document.querySelector('.menu') // Using a class instead, see note below.
menu.classList.toggle('hidden-phone');