如以下demo代码
$(document).ready(function(){
$("img").each(function () { //获取所有img元素,进行遍历
$("<img />").attr("src", this.src).on("load", function () { //这里使用的jquery新建一个img对象进行添加attr属性,把src添加上去,然后进行载入事件
var imgw = this.width; //这里的width和height就是图片实际的宽高了
var imgh = this.height;
alert("imgw:" + imgw + ',' + "imgh:" + imgh);
});
});
});原文:http://blog.51cto.com/smly1989/2058068