Я хочу установить равную высоту для div с jQuery. У всех разделов может быть разное количество контента и разная высота по умолчанию. Вот пример моего макета html:
<div class="container">
<div class="column">This is<br />the highest<br />column</div>
<div class="column">One line</div>
<div class="column">Two<br />lines</div>
</div>
<div class="container">
<div class="column">One line</div>
<div class="column">Two<br>lines</div>
<div class="column">One line</div>
</div>
Я устанавливаю высоту с помощью следующей функции jQuery:
$(document).ready(function(){
var highestBox = 0;
$('.container .column').each(function(){
if($(this).height() > highestBox){
highestBox = $(this).height();
}
});
$('.container .column').height(highestBox);
});
Это работает отлично, но не в моем случае, потому что я хочу, чтобы все "столбцы" были равны только внутри одного "контейнера". Это означает, что в первом контейнере все поля должны быть выше первого, но во втором они должны быть равны второму столбцу.
Итак, вопрос в том, как мне изменить мой jQuery, чтобы достичь этого?
Спасибо!