获取原图宽度,高度

自己手写一个点击页面图片放大的效果。遇到获取原图尺寸问题
var img = $("#img_id"); 
var pic_real_width, pic_real_height;
$("<img/>") 
    .attr("src", $(img).attr("src"))
    .load(function() {
        pic_real_width = this.width;   // Note: $(this).width() will not
        pic_real_height = this.height; // work for in memory images.
    });
转载地址 http://www.webhek.com/post/get-real-image-width-and-height-with-javascript.html

猜你喜欢

转载自blog.csdn.net/qq_37337830/article/details/79282044