如何获得图像的实际宽度和高度 [英] how to get an image actual width and height
本文介绍了如何获得图像的实际宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
Get real image width and height with JavaScript in Safari/Chrome?
当图像在CSS中按比例缩小时,是否有一种方法可以使用jQuery知道图像的真实宽度和高度-无需任何额外的尺寸数据-任何链接或代码示例都将非常有用
Is there a way to know the true width and height of an image using jQuery when the image is scaled down in css - without any extra data of dimensions - any link or code example would be helpful thanks
推荐答案
尝试使用naturalWidth
和naturalHeight
.
var domElement = $('yourImage')[0]; // or document.getElementById('yourImageId');
domElement.naturalWidth
domElement.naturalHeight
这篇关于如何获得图像的实际宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文