jQuery实现定位滚动条位置实现定位滚动条位置
基于jQuery实现滚动条滚动到子元素位置以此来定位滚动条位置,下面是小编给大家带来的实现代码,代码比
较简单,需要的朋友可以参考下
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().top - $("#nurse").offset().top); --普通
$("#nurse").animate({ scrollTop: $("#nurse").scrollTop() + $('#tr-three').offset().top - $("#nurse").offset().top }, 1000); --有动画效果
以上所述是小编给大家介绍的jQuery实现定位滚动条位置,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及
时回复大家的。在此也非常感谢大家对我们网站的支持!