js获取图片的尺寸

$("<img/>").attr("src", "http://www.example.com/images/bag001.jpg").load(function() {
imgWidth = this.width;
imgHeight = this.height;
});

 

如果是设定了宽度获取高度,或者是,设定了高度获取宽度,那么只要知道真实的图片尺寸,然后获得百分比,计算出另外的宽或高的尺寸就可以了

posted @ 2017-10-10 16:23  西瓜霜  阅读(583)  评论(0编辑  收藏  举报