最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - click .toggle addremove class - Stack Overflow

programmeradmin1浏览0评论

When i click #tool I want to add the class .spanner to the div #drill.

However when #drill has the class .spanner and #tool is clicked i want the class to be removed?

When i click #tool I want to add the class .spanner to the div #drill.

However when #drill has the class .spanner and #tool is clicked i want the class to be removed?

Share Improve this question edited Apr 27, 2010 at 11:25 Andrew Hare 352k75 gold badges647 silver badges642 bronze badges asked Apr 27, 2010 at 11:21 CLiownCLiown 13.9k50 gold badges127 silver badges205 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Use the toggleClass function:

$("#tool").click(function() {
    $("#drill").toggleClass("spanner");
});
发布评论

评论列表(0)

  1. 暂无评论