Reputation: 1423
When I call $("body").animate({scrollTop: someValue});
I want $(window).scroll(function() { });
to be called too. How can I achieve that?
I have tried with $(window).trigger("scroll")
and $(window).triggerHandler("scroll")
without success.
EDIT:
Problem solved. There was an if
in my $(window).scroll(function() { });
that caused the problem.
Upvotes: 24
Views: 78332
Reputation: 601
Just use:
// Trigger the scroll event
$(window).scroll();
Source:
Upvotes: 50
Reputation: 344
You can try below code - here i am scrolling to top of my div tag which has id "one".
$('html,body').animate({ scrollTop: $('#one').offset().top }, 'slow');
Upvotes: 2
Reputation: 195982
Apply it to both body
and html
as it is not consistent.. (for example, FF uses the html
for scrolling while chrome uses the body
)
$("html, body").animate({scrollTop: someValue});
demo at http://jsfiddle.net/vzyVh/
Upvotes: 9