获取某div的高度,赋值给另一个div

来源:互联网 发布:手机在淘宝怎么看评估 编辑:程序博客网 时间:2024/05/21 10:02

modkong为赋值对象

简短版

<script type="text/javascript">

window.onload = function() {
document.getElementById("modkong").style.height=document.getElementById("divmid").offsetHeight + "px";
}

</script>



繁复版

<script type="text/javascript"> 
         function $(id){  
           return document.getElementById(id)  
        }  
        function getHeight() {  
          $("modkong").style.height=$("divmid").offsetHeight + "px";            
        }  
      window.onload = function() {  
          getHeight();  
         }  
   </script> 

0 0
原创粉丝点击