<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JS获取DIV动态高度,并赋值到其style样式中</title>
</head>
<script type="text/javascript">
function $(id){
return document.getElementById(id)
}
function getHeight() {
alert($("hidden").offsetHeight + "px");
$("pinglun").style.height=$("hidden").offsetHeight + "px";
}
window.onload = function() {
getHeight();
}
</script>
<style>
#hidden { width:100px; background:#99CC00; height:400px; float:left}
#pinglun { width:500px; height:auto; background:#FFCCCC; float:left; margin-left:5px;}
</style>
<body>
<div id="hidden">hidden</div>
<div id="pinglun" >评论数据载入中……</div>
</body>
</html>