1 var scrolltop = new Array(); 2 var index = 0; 3 scrolltop[0] = 0; 4 $(document).scroll(function(){ 5 index ++; 6 scrolltop[index] = $(document).scrollTop(); 7 if (scrolltop[index] > scrolltop[index-1]) { 8 console.log("scroll down"); 9 }else{ 10 console.log("scroll up"); 11 }; 12 })