English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The scroll() method triggers the scroll event or attaches a function to be executed when the scroll event occurs.
A scroll event occurs when the scrollbar of a scrollable element is scrolled.
The scroll event applies to all scrollable elements and window objects (browser window).
Trigger the scroll event of the selected element:
$(selector).scroll()
Attach the function to the scroll event:
$(selector).scroll(function)
Calculate the number of times scrolling is used for the window:
$(window).scroll(function() { $("span").text(x++); });Test and see‹/›
Calculate the number of times scrolling is used for the DIV element:
$("div").scroll(function() { $("span").text(x++); });Test and see‹/›
Parameters | Description |
---|---|
function | Function executed each time the scroll event triggers |