I have a table with cells of variable-length text-content. I want to find the height of the tallest cell and then make all the cells that height. How can I do this?
Like this:
var max = 0;
$('table td').each(function() {
max = Math.max($(this).height(), max);
}).height(max);
In plain english, loop through all the cells and find the maximum value, then apply that value to all the cells.
Just to be different:
var heights = $('td').map(function() {
return $(this).height();
}).get();
var maxHeight = Math.max.apply(Math, heights);
$('td').css('height', maxHeight);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With