jquery获取网络图片宽高
前提是图片路径是正确的...
var img = new Image(); img.src="http://www.baidu.com/img/baidu_sylogo1.gif"; img.onload = function(){ alert(this.width); alert(this.height); this.onload=null; }
通过$("#img").attr("width");这种方式获取的值,在图片没有加载完成的时候,是不正确的
前提是图片路径是正确的...
var img = new Image(); img.src="http://www.baidu.com/img/baidu_sylogo1.gif"; img.onload = function(){ alert(this.width); alert(this.height); this.onload=null; }
通过$("#img").attr("width");这种方式获取的值,在图片没有加载完成的时候,是不正确的