$(".btn-close").on('click', function () {
alert('click');
var win = $(this).closest("div.window");
var winID = win.attr("id");
$(win).find("*").each(function () {
var timerid = $(this).attr("data-timer-id");
if (timerid != null || timerid != 'undefined') {
window.clearInterval(timerid);
}
});
if (winID != 'undefined' || id != null) {
$('#' + winID).remove();
}
});
So since i'm using .on('click'), I thought this would handle dynamically added items to the dom or is that not correct?
I'm prepending items to an element via ajax when a user clicks a button. but when I click on it to close, the event doesn't fire.
What is the best way to handle this?