how to add and remove class on click in jquery with timimg code example
Example 1: jquery remove and add class
$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );
//OR
if ($( "#foo" ).hasClass('className')) {
$( "#foo" ).removeClass( 'className');
} else {
$( "#foo" ).addClass( 'className');
}
Example 2: add and remove class in jquery
$('#toggle li').on('click', function () {
$(this).toggleClass('open')
});