js滑动展开与折叠效果(收缩)

 

<script type="text/javascript">
//Url: http://bbs.51js.com/thread-61646-1-1.html
//
Author: 风云突变
//
Modify: 枫岩
var act;
function over(s,nMax){
  
var obj=document.getElementById(s);
  
var h = parseInt(obj.offsetHeight);
  
if (h < nMax){
    obj.style.height 
= (h + 2)+"px";
    clearTimeout(act);
    act 
= setTimeout("over('"+s+"',"+nMax+")"10);
  }
}
function out(s,nMin){
  
var obj=document.getElementById(s);
  
var h = parseInt(obj.offsetHeight);
  
if (h > nMin){
    obj.style.height 
= (h - 2)+"px";
    clearTimeout(act);
    act 
= setTimeout("out('"+s+"',"+nMin+")"10);
  }
}
</script>
<div id="mytd" onmouseover="over('mytd',200);" onmouseout="out('mytd',30);" style="background:#eee;">代码实例:层的滑动展开/折叠</div>
posted on 2008-01-11 10:10  radman  阅读(1867)  评论(0)    收藏  举报