首页 > 编程 > JavaScript > 正文

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

2019-11-19 18:05:01
字体:
来源:转载
供稿:网友

 话不多说,请看代码:

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

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表