i’m adding a class to an <a> tag on “click”. now i need to remove this class when another <a> is clicked. how can i do this?
thanks
EDIT: the html is an unordered list
<ul>
<li><a href="">link1</a></li>
<li><a href="">link2</a></li>
<li><a href="">link3</a></li>
<li><a href="">link4</a></li>
</ul>
without knowing the html, this is rough.
crazy demo
based on your EDIT, the best approach I could suggest is
humble demo
if your classes are just meant for CSS purpose, I would suggest to add/remove class on
li, to minimize codes on javascript part.then have your CSS
Before
after
cool demo