jQuery > Events

Scroll event in jQuery

How to attach scroll event to a html element in jQuery?

To attach scroll event to a html element, scroll() method can be used.

        $(window).scroll(function () {
            $("#divScroll").css("display", "inline").text("You are scrolling").fadeOut("slow");

In the above code when user scrolls the window then “You are scrolling” text is written in the “divScroll” element with fading effect slowly (we will learn about .fade() method in following post).

 Views: 4750 | Post Order: 83

Write for us

Hosting Recommendations