admin管理员组

文章数量:1435859

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");
});

本文标签: javascriptclick toggle addremove classStack Overflow