So I need a little bit of help. I'm playing around with addClass
and removeClass
and I can't seem to remove a class after it's set. What I basically want is:
- When someone clicks an
h3
, it adds to its parentdiv
class - When someone clicks a
div
with added class, class needs to be removed
First step I got out of way and it's working
$(function(){
$('div h3.itemTitle').on('click', function(){
$(this).parent().addClass('active').siblings().removeClass('active');
});
});
Now when I define:
$(function(){
$('div.active').on('click', function(){
$(this).removeClass('active');
});
});
It does nothing, as if it doesn't see classes. It sets only those set in onload
...
Help, anyone?