加载图像后获取图像高度 [英] Get image height after image has loaded
本文介绍了加载图像后获取图像高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在图像加载后获得图像高度.这样做的原因是chrome获得错误的高度值,因为它在加载图像之前获得了高度.
I am trying to get image height after image has loaded. The reason for that is chrome gets false height values because it gets height before image has loaded.
var imgHeight = $("#pic25").height();
注意:我不应该在这上面使用$(window).load(function(){
.
Note: I shouldn't use $(window).load(function(){
on this one.
我该怎么做?
推荐答案
$("img#pic25").load(function(){
var height = $(this).height();
});
这篇关于加载图像后获取图像高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文