totneschap
totneschap

Reputation: 380

Add class on click and then remove it on click

Is there anyway to add a class on click and then remove that class when clicked again.

This is as far as I have got but everything I have tried to remove the class isn't working.

$(".meganav-toggle").click(function(){
$(".offcanvas-menu-left").addClass("activo");

Many thanks

Upvotes: 0

Views: 73

Answers (2)

Void Spirit
Void Spirit

Reputation: 909

Use jQuery's toggle class

$(".offcanvas-menu-left").toggleClass("active")

Upvotes: 2

larz
larz

Reputation: 5766

$(".meganav-toggle").click(function(){
  $(".offcanvas-menu-left").toggleClass("activo");

Upvotes: 2

Related Questions