I needed to equalize the heights on a few container divs for the office the other day.
Math.max is clearly the method to use to calculate the largest pixel height, but it bothers me to call this over and over again.
Instead, I loop through all the elements in my jQuery selector, append the heights to an array, then use
Math.max to pass the array instead of arguments. One call instead of many. Quarters of milliseconds saved!
The width version is the same as the height. Only the affected dimensions change. Note I’ve added
average methods as options as well.