1Check current scrollTop vs previous scrollTop
2
3var lastScrollTop = 0;
4$(window).scroll(function(event){
5 var st = $(this).scrollTop();
6 if (st > lastScrollTop){
7 // downscroll code
8 } else {
9 // upscroll code
10 }
11 lastScrollTop = st;
12});
1Syntax
2Trigger the scroll event for the selected elements:
3$(selector).scroll()
4
5Attach a function to the scroll event:
6$(selector).scroll(function)