How to set the height in javascript: first get the element with the specified id; then get the current height of "p_count"; finally pass "$("p_count").style.height="900" "px";" Just set a fixed height.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
How to set javascript to high?
js sets the height of the specified div
The code is as follows:
<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.οnlοad=function(){ getHeight(); } </script> <div id="p_count" style="border:1px solid #ccc">lalala</div>
[Related recommendations: javascript advanced tutorial]
The above is the detailed content of How to set high in javascript. For more information, please follow other related articles on the PHP Chinese website!