JQuery元素滚动定位及获取元素的scrollTop,clientHeight,scrollHeight

 

 

 

scrollHeight为滚动DIV的实际总体高度,获取方式为:$(obj)[0].scrollHeight

clientHeight为滚动DIV的可见高度,获取方式为:$(obj)[0].clientHeight

scrollTop为滚动DIV被卷去的上端高度,获取方式为:$(obj).scrollTop

offset为元素的偏移量,获取方式为:$(obj).offset().top

 

JQuery元素滚动定位

<div id="scroll">
    ...
    <div id="row8">...</div>
    ...
</div>

 

var container = $("#scroll");
var scrollTo = $("#row8");
var t = scrollTo.offset().top - container.offset().top + container.scrollTop();

container.animate({ scrollTop: t }, 500);

 

相关文章:

  • 2021-12-19
  • 2021-11-28
  • 2022-01-03
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-26
  • 2021-07-30
  • 2022-02-19
  • 2022-12-23
  • 2021-12-28
  • 2021-12-13
相关资源
相似解决方案