There is another way, for images, to automatically can be associated with FancyBox without even need to wrap - .wrap() - them with an anchor. A different approach would be to link them directly to fancybox on click like :
$(document).ready(function () {
$("img")
.css("cursor", "pointer")
.on("click", function(){
$.fancybox($(this).attr("src"),{
'type': 'image',
'overlayShow': false,
'transitionIn': 'elastic',
'transitionOut': 'elastic'
});
});
});
In this way, it does not process anything until the actual image is clicked. This would be better in terms of performance (consider 200+ images being wrapped every page load).
Posted On:
17-Sep-2019 08:00