2021年4月23日星期五

JQuery add and remove class onclick

I wanted to show and remove css class when the button is clicked, i know there's a solution using toggleclass() but i want to add class using onClick function.

Here's the code

  jQuery(document).ready(function(){  jQuery(".main-header-menu-toggle").click(function () {  jQuery("body").addClass('ast-main-header-nav-open');  });  });  

i want to add class to body, it worked when i click on the button but when i again close the button it doesn't remove the class.

https://stackoverflow.com/questions/67238774/jquery-add-and-remove-class-onclick April 24, 2021 at 10:20AM

没有评论:

发表评论