jQuery实现滚动条滚动到子元素位置(方便定位)

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

jQuery实现滚动条滚动到子元素位置(方便定位)

Mr.Bruce   2020-05-15 我要评论

 话不多说,请看代码:

<div class="of-y" id="nurse" >
  <table class="high width" id="nurse-plan">
    <tr id="tr-one"></tr>
    <tr id="tr-two"></tr>
    <tr id="tr-three"></tr>
    <tr id="tr-four"></tr>
  </table>
</div>

jQuery:

$("#nurse").scrollTop($("#nurse").scrollTop() + $('#tr-three').offset().top - $("#nurse").offset().top); --普通

$("#nurse").animate({ scrollTop: $("#nurse").scrollTop() + $('#tr-three').offset().top - $("#nurse").offset().top }, 1000); --有动画效果

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们