我正在尝试根据图像的尺寸禁用 jquery 插件,因此如果图像> 500x480 则启用插件,否则如果图像低于该尺寸则禁用插件。
我尝试的方法不起作用。有人可以帮帮我吗?
插件的原始功能
$(function(){
$('#zoom1').bind('click',function(){
var cloudZoom = $(this).data('CloudZoom');
cloudZoom.closeZoom();
$.fancybox.open(cloudZoom.getGalleryList());//
return false;
});
});
CloudZoom.quickStart();
我试过的,
var img = document.getElementById('#zoom1');
var width = img.naturalWidth;
var height = img.naturalHeight;
$(function(){
$('#zoom1').bind('click',function(){
var cloudZoom = $(this).data('CloudZoom');
cloudZoom.closeZoom();
$.fancybox.open(cloudZoom.getGalleryList());//
return false;
});
});
if(var width > 500 || height > 480) {
CloudZoom.quickStart();//I would like to initiate this.
}
html
<div class="imgwrap">
<div class="sldwrp">
<div class="sldimgwrp">
<?php if($result->num_rows > 0){ if ($row['image_one'] != '') {?>
<img class="cloudzoom appsld" id ="zoom1" src="<?php echo $path.$row['image_one'];?>"
title="Click to view larger image."
data-cloudzoom='
zoomImage:"<?php echo $path.$row['image_one'];?>",
zoomSizeMode: "image",
captionPosition:"top",
maxMagnification:"4"
'><?php }}?>
</div>
<div class="thumbs">
<div class="thumb_img">
<?php if($result->num_rows > 0){ if ($row['image_one'] != '') {?>
<a href="<?php echo $path.$row['image_one'];?>" class="thumb-link">
<img class="cloudzoom-gallery" id="thumbwd" src="<?php echo $path.$row['image_one'];?>"
data-cloudzoom='
useZoom:"#zoom1",
image:"<?php echo $path.$row['image_one'];?>",
zoomImage:"<?php echo $path.$row['image_one'];?>"'>
</a>
<?php }}?>