Why is this not working? I'm going absolutely nuts.
<span class="fav"></span>
$('.fav').on('click', function() {
$(this).addClass('item-selected');
});
$('.fav.item-selected').on('click', function() {
$(this).removeClass('item-selected');
});
BELOW IS FULL CODE. It's the second part that wont undo.
$('.fav').on('click', function() {
$(this).addClass('item-selected').next('span.notification').toggleClass('show-notification').html("Hello world!");
setTimeout(function(){
$('.show-notification').removeClass('show-notification');
},4000);
});
$('.fav.item-selected').on('click', function() {
$(this).removeClass('item-selected').next('span.notification').toggleClass('show-notification').html("Goodbye world!");
setTimeout(function(){
$('.show-notification').removeClass('show-notification');
},4000);
});