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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -