本文主要介绍了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实现滚动条滚动到子元素位置请关注PHP中文网(www.php.cn)其他文章!