Good night, I'm trying to create a page that displays an image in a modalBox with the zoom function, but I'm facing the problem that even if you click outside the image thumbnail, the zoom function is running, solve? The code is below:
<span class='zoom' id='ex3'>
<img id="myImg" src="http://t.wallpaperweb.org/wallpaper/nature/1920x1200/Trolltunga_Odda_Norway.jpg"alt="Trolltunga, Norway" width="300" height="200">
<p>Hover</p>
</span>
<div id="myModal" class="modal">
<span class="close">×</span>
<div class="zoom">
<img class="modal-content" id="img01" width=300 height=300>
</div>
<div id="caption"></div>
</div>
$(function(){
var modal = document.getElementById('myModal');
var img = document.getElementById('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function() {
modal.style.display = "block";
modalImg.src = this.src;
captionText.innerHTML = this.alt;
$('.zoom').zoom({
on: 'click',
url: this.src
});
}
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
})