jQuery实现定位滚动条位置

网络编程 2021-07-04 20:00www.168986.cn编程入门
基于jQuery实现滚动条滚动到子元素位置以此来定位滚动条位置,狼蚁网站SEO优化是长沙网络推广给大家带来的实现代码,代码比较简单,需要的朋友可以参考下

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

关键代码如下所示:

<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(). - $("#nurse").offset().); --普通
$("#nurse").animate({ scrollTop: $("#nurse").scrollTop() + $('#tr-three').offset(). - $("#nurse").offset(). }, 1000); --有动画效果

以上所述是长沙网络推广给大家介绍的jQuery实现定位滚动条位置,希望对大家有所帮助,如果大家有任何疑问请给我留言,长沙网络推广会及时回复大家的。在此也非常感谢大家对狼蚁SEO网站的支持!

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by