All the solutions provided force you to know the element you will click beforehand. If you want to get the class from any element clicked you can use: function(e) clickedid e. target. id; clickedclass ( ' do stuff with ids and classes ) jquery change class when clicked I have two css classes that either show a silver button (squarebutton) for each link by default or, if clicked, the link will be a blue button (bsquarebutton) showing that it was last clickedis active. Each class has all. a behaviors defined such as activehoveretc. The only difference is a button graphic.
This is changing my class name from account to accountselected, which is great but what I need it to do is when another div is clicked is change the class back to account and set the one that was clicked to accountselected. jquery change class when clicked