The following code adds data to the container #section via ajax:
$(".btnGetImages").click(function(event){
event.preventDefault();
// get id of article
var id = $(this).attr('data-id');
// get images via ajax
$.ajax({
url: "includes/get_images.php",
type: "get",
data: {article:id},
success: function(data) {
// insert data into container
$("#section").html(data);
},
error:function() {
$("#section").html('show error msg here...');
}
});
});
Inside the container #section there are elements with a class .thumb that i would like to click. For some reason, the click doesn't trigger, even though i added the .on event correctly. Why?
$(".thumb").on("click", function(event) {
alert('yo, im a thumb...');
event.preventDefault();
});