onscroll jquery – jquery on scroll event Example

onscroll jquery A scroll event is sent whenever the element’s scroll position changes, regardless of the cause.

onscroll jquery

The event is triggered when the user moves the scrollbar up or down. jQuery scroll() function triggers when the element is scrolled.

Syntax of jquery on scroll

Trigger the scroll event for the selected elements:


Attach a function to the scroll event:


jquery on scroll down

Check current scrollTop vs previous scrollTop

var endScrlTp = 0;
   var st = $(this).scrollTop();
   if (st > endScrlTp){
       // downscroll source code
   } else {
      // upscroll source code
   endScrlTp = st;

jQuery scroll() method



Welcome To Pakainfo.com :):)

Scroll the bordered text to see the effect.

This is an example of using the scroll() method.

Pakainfo.com website focuses on all web language and framework tutorial PHP, Laravel, Codeigniter, Nodejs, API, MySQL, AJAX, jQuery, JavaScript, Demo.

Don’t Miss : Add Class On Scroll Jquery

I hope you get an idea about onscroll jquery.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this Article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment