jQuery Realizes Scroll Bar Position
- 2021-07-09 06:49:32
- OfStack
jQuery enables scroll bars to scroll to child element positions (easy positioning)
The key code is as follows:
<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); -- Ordinary
$("#nurse").animate({ scrollTop: $("#nurse").scrollTop() + $('#tr-three').offset().top - $("#nurse").offset().top }, 1000); -- Have animated effect