Latest web development tutorials

jQuery scroll () method

jQuery Event Methods jQuery Event Methods

Examples

For counting the number of rolling elements:

$("div").scroll(function(){
$("span").text(x+=1);
});

try it"

Definition and Usage

When the user scrolls the specified elements, scroll event occurs.

scroll event applies to all scrollable elements and window objects (browser window).

scroll () method triggers the scroll event, or when a predetermined function to run when the event occurs scroll.


grammar

Trigger the selected element scroll events:

$(selector).scroll() 尝试一下

Add functions to the scroll event:

$(selector).scroll(function) 尝试一下

参数 描述
function 可选。规定当 scroll 事件被触发时运行的函数。


jQuery Event Methods jQuery Event Methods