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
Post a Comment