Reputation: 2385
I'm trying to get jquery to run some code every time that the window is scrolled. The function works fine if I call it from some other function (for example, calling $(window).scroll from inside another working function, but will not execute natively on a scroll itself. Any ideas what could cause this problem?
For example:
$('.someDiv').click(function() {
$(window).scroll();
});
$(window).scroll(function() {
//do some code
});
'some code' only executes when I click on "someDiv" but will not execute on the scrolling of the window.
Upvotes: 0
Views: 169
Reputation: 2907
try this:
$(window).resize(function() {
$(window).scroll();
});
Upvotes: 0
Reputation: 2818
try binding to body:
$('body').scroll(function(){
//Do Something
})
Upvotes: 1