$(window).scrollTop() vs. $(document).scrollTop()

frenchie picture frenchie · Mar 20, 2011 · Viewed 364.7k times · Source

What's the difference between:

$(window).scrollTop()

and

$(document).scrollTop()

Thanks.

Answer

Bodman picture Bodman · Mar 20, 2011

They are both going to have the same effect.

However, as pointed out in the comments: $(window).scrollTop() is supported by more web browsers than $('html').scrollTop().