Scroll to a particular element w/ jQuery

后端 未结 3 673
情深已故
情深已故 2021-01-03 00:33

I have a long list of nested divs. I am passing the ID of a particular element (actually a paragraph element) on the querystring and opening its div and parent onload. How

相关标签:
3条回答
  • 2021-01-03 01:00

    The easiest way to do this is by using Ariel Flesler's scrollTo plugin. I've used it a few times before and it is small, lightweight and works very well.

    0 讨论(0)
  • 2021-01-03 01:03

    You could use the scrollIntoView function.

    $(document).ready(function() {
      $('#divN').get(0).scrollIntoView();
    });
    
    0 讨论(0)
  • 2021-01-03 01:26

    jQuery:

    $(document).ready(function(){
       $(document.body).scrollTop($('#divN').offset().top);
    });
    
    0 讨论(0)
提交回复
热议问题