我想獲得窗口調整大小的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
上面的代碼對我來說工作正常,添加正確的代碼來重現問題。 –