<script type="text/javascript">
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>
本文介绍了一种使用JavaScript实现的层滑动展开与折叠效果。通过设置元素的高度属性,可以平滑地改变层的高度,从而达到展开或折叠的效果。该方法适用于网页中需要交互展示更多内容或隐藏内容的场景。
9686

被折叠的 条评论
为什么被折叠?



