| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 415 人关注过本帖
标题:求大大,达人们帮帮我吧!~
取消只看楼主 加入收藏
gtf7801524
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-3-29
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
求大大,达人们帮帮我吧!~
<script type="text/javascript">
var mh = 30;//高度
var step = 5;//每次变化的量
var ms = 10;//循环时间
function toggle(o){
  if (!o.tid)o.tid = "_" + Math.random() * 100;
  if (!window.toggler)window.toggler = {};
  if (!window.toggler[o.tid]){
    window.toggler[o.tid]={
      obj:o,
      maxHeight:o.offsetHeight,
      minHeight:mh,
      timer:null,
      action:1
    };
  }
  o.style.height = o.offsetHeight + "px";
  if (window.toggler[o.tid].timer)clearTimeout(window.toggler[o.tid].timer);
  window.toggler[o.tid].action *= -1;
  window.toggler[o.tid].timer = setTimeout("anim('"+o.tid+"')",ms );
}
function anim(id){
  var t = window.toggler[id];
  var o = window.toggler[id].obj;
  if (t.action < 0){
    if (o.offsetHeight <= t.minHeight){
      clearTimeout(t.timer);
      return;
    }
  }
  else{
    if (o.offsetHeight >= t.maxHeight){
      clearTimeout(t.timer);
      return;
    }
  }
  o.style.height = (parseInt(o.style.height, 10) + t.action * step) + "px";
  window.toggler[id].timer = setTimeout("anim('"+id+"')",ms );
}
</script>
<style type="text/css">
div.xx{border:solid 0px;overflow:hidden;}
div.xx h5{border:solid 0px;border-width:0 0 0px;padding:0;margin:0;height:28px;line-height:30px;cursor:pointer;background:#eee;}
</style>
</head>
<body>
<div class="xx"><h5 onclick="toggle(this.parentNode)">点击此处层伸缩</h5>
<p>test</p>
</div>
</body>

文字点击展开效果,可如让文字默认是收缩着的呢?求达人教教我吧~谢谢...
搜索更多相关主题的帖子: 时间 null function 
2011-03-29 17:24
快速回复:求大大,达人们帮帮我吧!~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014192 second(s), 8 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved