I have a function that I bound with scroll() event, but the fact is I want the function to be triggered only in case of vertical scroll ( I have some horizontal
scroll()
You can also use .scrollTop to make a custom vertical scroll event.
.scrollTop
var prevTop = 0; $(document).scroll( function(evt) { var currentTop = $(this).scrollTop(); if(prevTop !== currentTop) { prevTop = currentTop; console.log("I scrolled vertically."); } });
Jquery .scrollTop()