I want to load a different image (A bigger version) of existing one when mouse is hovered over that image. So I place all the images through AJAX call
<main class="container">
<ul class="gallery">
</ul>
</main>
success: function (data) {
$.each(data, function (index, element) {
$(".gallery").append($(`<img src="${`images/square/${element.path}`}"
alt="${element.title}"id="${element.path}"city="${element.city}"
taken="${element.taken}"/>`));
});
},
Now I want to load a bigger image (from local disk) of existing image when mouse is hovered and show that image over it (kind of zoom in, but not zoom in over the image but load a bigger image, and append the div to body) in the body. I've tried many different versions of this
(".gallery").mouseenter(function(){
$(this).css("gray");
$(this).append('<div id="preview"');
// console.log($(this).attributes);
// $(this).append($(`<img src="${`images/medium/"${$(this).attr('id')}"`}"
// alt="${$(this).attr('title')}"/>`
// ));
$(this).append('</div>')
})
I am unable to access the attributes dynamically. this. attribute remains return undefined. Something seems off here. Can you please tell, how to go about it ?