I have this script and I would like to make it work with dinamically added elements from database:
$( ".select-song li" ).each(
function( intIndex ){
$( this ).bind (
"click",
function(){
if($(this).hasClass('checked')){
$(this).removeClass('checked');
}
else{
$(this).addClass('checked');
}
}
);
}
);
Elements are added in like this:
$('.select-song').append('<li>sth here</li>');
I know that I should to use on function but I have no idea how to implement it here.