how to toggle class in jquery code example
Example 1: toggle class javascript and jquery
$('.click-class').click(function() {
$('.class-toggle').toggle();
$('.class-toggle').toggleClass('add-class');
})
Example 2: toggle jquery remove others
$(".nav-link").click(function () {
if ($(this).hasClass("active")) {
$(".nav-link").removeClass("active");
}
else {
$(".nav-link").removeClass("active");
$(this).addClass("active");
}
});
Example 3: jquery toggle class
$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );
Example 4: toggle class jquery
toggleClass