• Welcome to Journal web site.

我是 PHP 程序员

- 开发无止境 -

Next
Prev

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

Data: 2013-10-19 13:51:36Form: JournalClick: 6

Mr.Bruce

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

Name:
<提交>