$(function() { var This = $('.height-a'), array = [], max, h, count = This.length; This.each(function(i) { array[i] = $(this); h = array[i].height(); if(i == 0 || h > max) max = h; if(i == count - 1) $.each(array, function() { this.height(max); }); }); });
<div class="height-a font-1"><p>Text</p></div> <div class="height-a font-2"><p>TextTextTextTextTextTextTextTextTextTextTextText</p></div> <div class="height-a font-3"><p>Text</p></div> <div class="height-a font-1"><p>TextTextTextTextTextTextTextTextText</p></div> <div class="height-a font-2"><p>Text</p></div>
div {overflow:hidden;} .height-a { background: #ededed; float: left; width: 60px; border: 1px solid #333; margin-right: 5px; word-break: break-all; } .font-1 { font-size: 20px; } .font-2 { font-size: 10px; } .font-3 { font-size: 30px; }