$(".sl3-big-image").on('load', function() {
alturaImg3 = $('.sl3-big-image').height();
$('.sl3-container').css('height',alturaImg3);
$('.sl3-container .sl2-container2').css('height',alturaImg3);
});
我认为.on('load',...)
是根本不工作..有时img高度为0.我试过这个,但它也不工作。图像高度返回0使用。负载
$(".sl3-big-image").on('load', function() {
alturaImg3 = $('.sl3-big-image').height();
$('.sl3-container').css('height',alturaImg3);
$('.sl3-container .sl2-container2').css('height',alturaImg3);
}).each(function() {
if(this.complete) $(this).load();
});
可能是什么问题?谢谢
我想你需要'$(本).height()' – Satpal
的事情数可能是错误的。很难说没有看到你的HTML,甚至CSS(你可以有'img {height:0}'等等)。如果您使用Chrome浏览器进行测试,请尝试'naturalHeight'。 – alex