When you start an HTML page you start with a certain set of elements. The user can then obviously add new elements to the page and those changes can immediately be viewed. One problem I have noticed though is that javascript/jquery isn't able to see these newly added elements, it is as though it can only see the elements that were present when the page was loaded (so the elements in the HTML page). Therefore you can't add any events to those new elements.
$('#old_element').on('click', function() {
var frag = $('<div class='new_element'></div>')
$('#old_element').append(frag);
})
$('.new_element').on('click', function() {
$(this).hide();
})
Here you can see an example I made.
I couldn't find any place that had an answer for this, so does anyone here have any?