[英]click .toggle add/remove class
When i click #tool
I want to add the class .spanner
to the div #drill
. 当我单击
#tool
我想将.spanner
类.spanner
到div #drill
。
However when #drill
has the class .spanner
and #tool
is clicked i want the class to be removed? 但是,当
#drill
具有类.spanner
和#tool
单击时,我要删除该类吗?
Use the toggleClass
function: 使用
toggleClass
函数:
$("#tool").click(function() {
$("#drill").toggleClass("spanner");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.