abstrakt:本文主要介紹了jQuery實現(xiàn)滾動條滾動到子元素位置的方法。具有一定的參考價值,下面跟著小編一起來看下吧<div class="of-y" id="nurse" > <table class="high width" id="nurse-plan&
本文主要介紹了jQuery實現(xiàn)滾動條滾動到子元素位置的方法。具有一定的參考價值,下面跟著小編一起來看下吧
<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實現(xiàn)滾動條滾動到子元素位置請關注PHP中文網(wǎng)(ipnx.cn)其他文章!