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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM