HTML
<div id='story'>
<div class='item folder'>sky</div>
<div class='item folder'>sea</div>
</div>
JS
$(".item").on('click', function(){
$('.marked').removeClass('marked');
$(this).addClass('marked');
});
This works but now the the content of #story
is replaced using ajax procedure:
...
success: function(data) {
$('#story').html(data);
}
And the new content is:
<div class='item folder'>earth</div>
<div class='item folder'>venus</div>
And here on('click', function()
doesn't work. Classes are not removed/added.