CLiown
CLiown

Reputation: 13843

click .toggle add/remove class

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?

Upvotes: 2

Views: 2842

Answers (1)

Andrew Hare
Andrew Hare

Reputation: 351456

Use the toggleClass function:

$("#tool").click(function() {
    $("#drill").toggleClass("spanner");
});

Upvotes: 7

Related Questions