js如何获取div高度(js获取div高度auto)-冯金伟博客园

如何用js得到div高度

function adjustcolumnheight(){

var main col = window . document . getelementbyid(& # 39;主列& # 39;);

var left col = window . document . getelementbyid(& # 39;MainLeft & # 39);

var right col = window . document . getelementbyid(& # 39;MainRight & # 39);

var hMainCol = mainCol。偏高;

var hLeftCol = left col . offsetheight;

var hRightCol = right col . offsetheight;

var maxHeight = Math.max( hMainCol,Math.max(hLeftCol,hRightCol));

main col . style . height = max height

& # 39;px & # 39;

left col . style . height = max height

& # 39;px & # 39;

right col . style . height = max height

& # 39;px & # 39;

}上面的代码是获取3个DIV的高度,判断最高DIV的高度值,使另外两个较短DIV的高度等于最高的DIV。自己想清楚很简单。