我想获得窗口调整大小的div标记的高度,但我总是获得相同的高度。正确触发事件大小调整。jQuery的窗口调整大小获取元素的高度
var resizeNews = this.resizeNews = function() {
$('.top-news__pillar').each(function (index){
console.log($(this).outerHeight());
if($(this).outerHeight() > maxHeightPillar) maxHeightPillar = $(this).outerHeight();
});
/如果我不设置高度以下的高度调整/
$('.top-news__pillar').each(function (index){
$(this).outerHeight(maxHeightPillar);
});
}
$(window).on('resize',resizeNews);
那么,当窗口大小调整时,通常元素会改变它们的宽度......你为什么期望它们改变高度? – MysterX
是否有'top-news__pillar'的CSS'height'? – tech2017
上面的代码对我来说工作正常,添加正确的代码来重现问题。 –