jquery how to get the page's current screen top position?

后端 未结 2 671
感情败类
感情败类 2020-12-14 14:30

jquery how to get the page\'s current screen top position?

If I scroll my mouse wheel to some part of the page, how do I get the page\'s current top position?

相关标签:
2条回答
  • 2020-12-14 14:55
    var top = $('html').offset().top;
    

    should do it.

    edit: this is the negative of $(document).scrollTop()

    0 讨论(0)
  • 2020-12-14 15:11

    Use this to get the page scroll position.

    var screenTop = $(document).scrollTop();
    
    $('#content').css('top', screenTop);
    
    0 讨论(0)
提交回复
热议问题