关注图老师设计创意栏目可以让大家能更好的了解电脑,知道有关于电脑的更多有趣教程,今天给大家分享JS实现滑动展开与折叠效果教程,希望对大家能有一点小小的帮助。
【 tulaoshi.com - Web开发 】
以下是引用片段:
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
无忧网友 fangxiao9159 再次优化后:
以下是引用片段:
script type="text/javascript"
var intervalId = null;
function move(id,state){
var obj = document.getElementById(id);
if(intervalId != null)
window.clearInterval(intervalId);
function change(){
var h = parseInt(obj.offsetHeight);
obj.style.height = (state == "down") ? (h + 2) : (h - 2);
}
intervalId = window.setInterval(change,10);
}
/script
table border="1" cellpadding="0" cellspacing="0" id="mytd" onmouseover="move(''mytd'',''down'');" onmouseout="move(''mytd'',''out'');"
trtd无忧脚本 - 风云突变/td/tr/table
来源:http://www.tulaoshi.com/n/20160219/1610206.html
看过《JS实现滑动展开与折叠效果》的人还看了以下文章 更多>>