jquery gzoom how to set default image size to defu

2019-09-04 07:24发布

问题:

i am attempting to use jquery gzoom:

http://lab.gianiaz.com/jquery/gzoom/

This is my jquery:

 $(".zoom_no_lbox").gzoom({
    sW: 800,
    sH: 500,
    lW: 1600,
    lH: 1000,
    lightbox: true
});

This is my image:

<div class="zoom zoom_no_lbox" id="zoom02"><img src="uploads/007/pg_0009.jpeg" alt="007" class=" "></div>

but as you can see in the gzoom function i have put in the size of the image. However, the images on the page are loaded dynamically and can vary in default length. So how can i set the default to be the default of the image?

回答1:

firstly give your image an id and after that

$('#ImageId').load(function(){
$(".zoom_no_lbox").gzoom({
    sW: value,
    sH: value,
    lW: value,
    lH: value,
    lightbox: true
});
});

try to set value here by getting attributes of image



标签: jquery zoom