备份资料

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
* {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
</style>
<script type="text/javascript">
/* 
函数名称: Scroll 
Scroll(obj, h, s) 
参数说明: 
obj,[object] id值或对象. 必需 
h,[height] 展开后的高度. 可选(默认为200px) 
s,[speed] 展开速度,值越小展开速度越慢. 可选(默认为1.2){建议取值为1.1到2.0之间[例如:1.17]}. 
函数返回值: 
true 展开(对象的高度等于展开后的高度) 
false 关闭(对象的高度等于原始高度) 
*/
function Scroll(obj, h, s) {
var h = h || 200;
var s = s || 1.2;
var obj = typeof (obj) == "string" ? document.getElementById(obj) : obj;
if (obj == undefined) {
return false;
}
var status = obj.getAttribute("status") == null;
var oh = parseInt(obj.offsetHeight);
obj.style.height = oh;
obj.style.display = "block";
obj.style.overflow = "hidden";
if (obj.getAttribute("oldHeight") == null) {
obj.setAttribute("oldHeight", oh);
} else {
var oldH = Math.ceil(obj.getAttribute("oldHeight"));
}
var reSet = function() {
if (status) {
if (oh < h) {
oh = Math.ceil(h - (h - oh) / s);
obj.style.height = oh + "px";
} else {
obj.setAttribute("status", false);
window.clearInterval(IntervalId);
}
} else {
obj.style.height = oldH + "px";
obj.removeAttribute("status");
window.clearInterval(IntervalId);
}
}
var IntervalId = window.setInterval(reSet, 10);
return status;
}
window.onload = function() {
var $ = function(id) {
return document.getElementById(id)
};


$('menu').onclick = function() {
Scroll('menu', this.scrollHeight, 2.0);
return true;
}
}
</script>
</head>
<body>
<div id="menu"
style="position: absolute; top: 10px; border: 1px solid #ccc; width: 300px; height: 30px; text-align: center; cursor: pointer; overflow: hidden;">
<br> 1<br> 2<br> 3<br> 4<br> 5<br> 6<br>
7<br> 8<br> 9<br> 10<br> 11<br>
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值