[英]Jquery get height of fluid image
I need to get the height of an image and apply the height to another div. 我需要获取图像的高度并将该高度应用于另一个div。 This is easy using
这很容易使用
$(window).load(function() {
var img_height = $('#image').height();
$('.some_div').css('height', img_height);
});
however... the image is set to width 100% and changes size when re-sizing the browser window. 但是...将图像设置为宽度100%,并在调整浏览器窗口大小时更改大小。 Is it possible to get the live height of the image?
是否可以获取图像的实时高度?
You can use window resize
callback 您可以使用窗口
resize
回调
$(window).resize(function(){
var img_height = $('#image').height();
$('.some_div').css('height', img_height);
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.