jQuery获取图片真实尺寸
程序员文章站
2024-03-18 18:46:34
...
jQuery获取图片真实尺寸
var imgList = new Array();
window.onload = function() {
var picRealWidth, picRealHeight;
$('.gallery-thumbs .swiper-slide').each(function(){
var _image = $(this).find('img')[0];
if (typeof _image.naturalWidth == "undefined") {
var i = new Image();
i.src = _image.src;
picRealWidth = i.width;
picRealHeight = i.height;
}
else {
picRealWidth = _image.naturalWidth;
picRealHeight = _image.naturalHeight;
}
imgList.push({src: _image.src, w: picRealWidth, h: picRealHeight})
});
}
上一篇: 利用栈实现十进制到其它进制转换