[英]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 非常感谢
$(".meganav-toggle").click(function(){
$(".offcanvas-menu-left").toggleClass("activo");
使用jQuery的toggle类
$(".offcanvas-menu-left").toggleClass("active")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.