I have this code below. As you can guess, when I press on "foobar", a new element is added. The problem: when I click on the the new element nothing happens, why? Im using jQuery 2.1.
<div>
<span>foobar</span>
</div>
<script type="text/javascript">
$("span").on('click', function() {
$(this).clone().appendTo('div').addClass('new');
alert("click on first element");
});
$(".new").on('click', function() {
alert("click on second element");
});
</script>