Syntax Trigger the scroll event for the selected elements: $(selector).scroll() Attach a function to the scroll event: $(selector).scroll(function)
$("#main-div" ).on( 'wheel', function() { alert("Hello! I am an alert box!!"); });
window.onscroll = function() {myFunction()}; function myFunction() { if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) { document.getElementById("myP").className = "test"; } else { document.getElementById("myP").className = ""; } }