scrollTop() returns 0 in Firefox, but not in Chrome December 23, 2023 by Tarik Try to use var scrollTop = $(document).scrollTop();