Get full size of image in javascript/jquery

后端 未结 4 1764
甜味超标
甜味超标 2021-02-15 02:53

I have an image on page that has been resized to fit in a div, say, 400x300. How can I get the full size of the image (~4000x3000) in jQuery? .width() and .height() only seem to

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-15 03:29

    Try this:

    var pic = $("img")

    // need to remove these in of case img-element has set width and height pic.removeAttr("width"); pic.removeAttr("height");

    var pic_real_width = pic.width(); var pic_real_height = pic.height();

提交回复
热议问题