views:

120

answers:

2

Hi, I'm using this mootools javascript snippet to equalize the height of my columns:

window.addEvent('domready', function() 
{
    var columns = $$('.equalize');
    var max_height = 0;

    columns.each(function(item) 
    { max_height = Math.max(max_height, item.getSize().y); });

    columns.setStyle('height', max_height);
});

Problem is it's not working properly on Chrome. It's getting the minimum height of the 2 columns instead of getting the maximum. What seems to be the problem and how do I fix it? Thanks in advance!

+1  A: 

Sorry to go on a different track - but why are you using JavaScript to do this? It can be accomplished with CSS, and even tables I feel are a better solution then doing it with JS.

alex
`display: table[-row|-cell]` is a bit better solution.
Crozin
@Crozin It certainly is, unless you require it work in IE6 / 7.
alex
A: 

You should use

window.addEvent('load', function(){ });

not the 'domready' event for this.

Some elements may not be loaded yet when the 'domready' event is fired.

kaizer