How do I determine height and scrolling position of window in jQuery?
from http://api.jquery.com/height/ (Note: The difference between the use for the window and the document object)
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
from http://api.jquery.com/scrollTop/
$(window).scrollTop() // return the number of pixels scrolled vertically
From jQuery Docs:
const height = $(window).height();
const scrollTop = $(window).scrollTop();
http://api.jquery.com/scrollTop/
http://api.jquery.com/height/
$(window).height()
$(window).width()
There is also a plugin to jquery to determine element location and offsets
http://plugins.jquery.com/project/dimensions
scrolling offset = offsetHeight property of an element
Pure JS
window.innerHeight
window.scrollY
is more than 10x faster than jquery (and code has similar size):
Here you can perform test on your machine: https://jsperf.com/window-height-width