爱问知识人 爱问教育 医院库

JS代码如何实现DIV层折叠效果?

首页

JS代码如何实现DIV层折叠效果?

JS代码如何实现DIV层折叠效果?

提交回答

全部答案

    2018-10-27 19:52:15
  •   script type=text/javascriptvar mh = 30; //最小高度var step = 1; //每次变化的px量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。

    分***

    2018-10-27 19:52:15

类似问题

换一换

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):