I had a lot of good use of this little function that I came up with
function getH(id)
{
return document.getElementById(id).offsetHeight;
}
This will return the height of any given elements given to the function (by its identifier). So now we are on 1/3 of the way.
Then use the Math.max () function to get the height of the largest element.
var maxH = Math.max(getH("ID1"),getH("ID2"));
This is 2/3 of the way, YAY - now set the height of the elements to the same.
var x = document.getElementById("ID1");
var y = document.getElementById("ID2");
x.style.height = maxH +"px";
y.style.height = maxH +"px";
DONE !! - Now all together
I would suggest something like this
function setElementHeight()
{
var maxH = Math.max(getH("ID1"),getH("ID2"));
var x = document.getElementById("ID1");
var y = doc...("ID2");
x.style.height = maxH +"px";
y.style.height = maxH +"px";
}
This will set both IDs to the same height, and the height will be equal to the highest. This is what you want, isn't it?
- EDIT -
I would select an array if I were you. Just have 2 DIVs each with a unique identifier and make them equally tall based on this.
Molle source
share