Difference between $(‘body,html’).scrollTop(); and $(window).scrollTop();

I don’t really understand this because sometimes body,html works and sometimes window. I’ve already done 2 web pages (local) with jQuery; in the first one body,html works and in the other one it doesn’t, so I write window and work it, the first web page is just an html document with some css and the script for jQuery, the other one is a web page based in WordPress.org theme (my own theme).

Related posts

Leave a Reply

1 comment

  1. Body and Html are DOM objects therefore styling can be applied to them, In this case

    height:100%
    

    or

    position:fixed;
    

    As a result the html and body tags don’t move. make the scrolltop constantly 0