前提是图片路径是正确的...

    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");这种方式获取的值,在图片没有加载完成的时候,是不正确的

相关文章:

  • 2022-01-03
  • 2022-12-23
  • 2022-01-07
  • 2021-10-21
  • 2021-11-10
  • 2021-12-07
  • 2021-09-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案