offline version v3


⊗jsSpMWSE 31 of 281 menu

Scroll event in JavaScript

There is the scroll event that can be used to catch the moment when the user is scrolling the window. Let's try it:

window.addEventListener('scroll', function() { console.log('!'); });

We will display the current scroll from the top of the site:

window.addEventListener('scroll', function() { console.log(window.pageYOffset); });

When you scroll to the bottom of the page, display a message about it.

enru