I have this code that makes a kind of fancybox, it turns out well but I liked that the click on the image did not make the '#overlayFancy' disappear, it was good that only the click outside the image is to make it disappear with everything , although the image is within '#overlayFancy' that occupies 100% * 100% of the window and the image is in the middle of the window, 500px * 500px.
HTML:
<div class="wrapperExtraImg" style="background-image:url(<?php echo 'admin/' .$extraImg->extra_image_path; ?>)"></div>
<div id="overlayFancy"></div>
js: Zoom In
$(document).on('click', '.wrapperExtraImg' ,function(){
var image = $(this).attr('id');
$('#overlayFancy').stop().animate({
"opacity":"1"
}, 500);
$( "#overlayFancy" ).append( "<img src="+image+">" );
});
js: Disappear, return to page default
$(document).on('click', '#overlayFancy' ,function(){
$('#overlayFancy').stop().animate({
"opacity":"0",
}, 300);
$('#overlayFancy').children('img').remove();
});