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

(编辑:jimmy 日期: 2025/9/28 浏览:2)

 话不多说,请看代码:

<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); --有动画效果

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

一句话新闻
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。