javascript - jQuery 'scroll' not firing -


i have following:

 var onscroll = function () {         alert('scroll');  };  scrollarea = $('body');  scrollarea.on('scroll', onscroll); 

i can $('body').scrolltop(400) , body scrolls fine, alert never called when manually scroll. causing this?

don't use $('body'), either $(document) or $(window) catch scroll, this:

$(document).ready(function() {     $(document).scroll(function() {     console.log('scrolled ' + $(this).scrolltop());   }) }); 

here's working jsfiddle: https://jsfiddle.net/4rrm3myl/1/


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -