您的位置:首页 > Web前端 > JavaScript

js设置指定div的高度

2010-12-06 14:44 211 查看
<script type="text/javascript">

function $(id){ //获指定id的element,方法形如jQuery

return document.getElementById(id);

}

function getHeight(){

var a=$("p_count").offsetHeight; //得到p_count目前的高

if(a>1000)

{

//alert(a);

}

else{

$("p_count").style.height="900"+"px"; //设定定高

}

}

window.onload=function(){

getHeight();

}

</script>

<div id="p_count" style="border:1px solid #ccc">lalala</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: