I have a javascript function to check for hover on image and display a delete button. It's working on existing thumbnails when the page first loaded, but when I upload an image and prepend the data with ajax to existing thumbnail gallery the hover function is not working to the newly added thumbnails.
Here's the script which is on the document ready
$(".del_photo").hide(); // Initially hide all buttons
$('.photo-item').hover(function(){
$(this).find('.del_photo').fadeIn(1000);
}, function(){
$(this).find('.del_photo').fadeOut(1000);
});
thanks
According to the link gave by Olav, here's my new code.
$(document).on({
mouseenter: function () {
$(this).find('.del_photo').fadeIn(1000);
},
mouseleave: function () {
$(this).find('.del_photo').fadeOut(1000);
}
}, ".photo-item"); //pass the element as an argument to .on