<!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改变可以实现,求解.....
offsetHeight 是只读的 ....
只读的?哪有介绍吗?