jQuery Scroll Event

The scroll event runs when a scrollable element or the browser window is scrolled. It can fire many times during one scroll gesture, so handlers should stay lightweight.

Syntax Top ↑

$( window ).on( "scroll", function () {
    // Window scrolled.
});

Handle Element and Window Scrolling Top ↑

$( function () {
    $( "#t1" ).on( "scroll", function () {
        $( "#d1" ).text( "Textarea scrolling..." );
        setTimeout( function () {
            $( "#d1" ).text( "Textarea stopped..." );
        }, 500 );
    });

    $( window ).on( "scroll", function () {
        $( "#d1" ).text( "Window scrolling..." );
        setTimeout( function () {
            $( "#d1" ).text( "Window stopped..." );
        }, 500 );
    });
});

Example HTML Top ↑

<textarea id="t1" rows="5" cols="25">
Line one
Line two
Line three
Line four
Line five
Line six
</textarea>
<div id="d1" class="alert alert-primary">Scroll this page or textarea.</div>

For production interfaces, use a proper debounce/timer-reset pattern if you need to detect when scrolling has really stopped.

Window Events with jQuery






plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer