javascript - click .toggle addremove class - Stack Overflow

admin2025-04-26  7

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");
});
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745675072a313543.html

最新回复(0)