$(window).resize(equalHeight);
function equalHeight(){
$(".container").each(function(){
boxes = $(this).find('.heightHack');
maxHeight = Math.max.apply(
Math, boxes.map(function() {
return $(this).height();
}).get());
boxes.height(maxHeight);
});
}
上面的代碼我用來並排排列2
div,但它不是實時更新。我使用了resize()
方法。爲什麼?resize event not binding on binding function
什麼時候調整會發生什麼?它什麼都不做,因爲你需要? –