首页 新闻 会员 周边

offsetHeight无法赋值是什么原因?

0
[已解决问题] 解决于 2012-08-13 21:10
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
    <head>
        <title>逐渐隐藏</title>
        <script type="text/javascript">
        window.onload=function(){
            document.getElementById('bt1').onclick=function(){
                setInterval(function(){
                var h=parseInt(document.getElementById('div1').offsetHeight);
                h=h-4;
                if(h<=0){
                        h=0;
                    }
                    document.getElementById('div1').style.offsetHeight=h+'px';
                },100);
            };
        };
        </script>
    </head>
    <body>
        <input id="bt1" type="button" value="隐藏" diaplay="block"/>
        <div id="div1"style=" background-color: Blue; overflow: hidden;offsetHeight:200px;">
            <img src="image/00_06.jpg">
            <input type="button" value="点击"/>
            <input/>
            <p>今天天气不错!</p>
        </div>
    </body>
</html>



为什么   document.getElementById('div1').style.offsetHeight=h+'px';不能改变offsetHeight的值呢?用style.height改变可以实现,求解.....
轻狂の书生的主页 轻狂の书生 | 小虾三级 | 园豆:1042
提问于:2012-08-09 21:01
< >
分享
最佳答案
0
offsetHeight 是只读的 ....
奖励园豆:5
张坤 | 小虾三级 |园豆:1865 | 2012-08-09 21:22

只读的?哪有介绍吗?

轻狂の书生 | 园豆:1042 (小虾三级) | 2012-08-10 08:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册