Easy, but I can’t understand. I have a link called #title, and when you click on it, it toggles a div called #content. This works fine, but also, I am adding an “active” class to my #title link, and I cannot get rid of it, even with removeClass.
See the code above and a link to an example (the title should be red ONLY with the extension #content, not all the time).
$('#title').click(function() { $(this).addClass('active'); $('#content').toggle(); }), function() { $(this).removeClass('active'); };
http://jsfiddle.net/vY3WY/
source share