I have used a scrollTop
function in jQuery for navigating to top, but strangely \'the smooth animated scroll\' stopped working in Safari and Chrome (scrolling w
If it work all fine for Mozilla, with html,body selector, then there is a good chance that the problem is related to the overflow, if the overflow in html or body is set to auto, then this will cause chrome to not work well, cause when it is set to auto, scrollTop property on animate will not work, i don't know exactly why! but the solution is to omit the overflow, don't set it! that solved it for me! if you are setting it to auto, take it off!
if you are setting it to hidden, then do as it is described in "user2971963" answer (ctrl+f to find it). hope this is useful!
I had a same problem with scrolling in chrome. So i removed this lines of codes from my style file.
html{height:100%;}
body{height:100%;}
Now i can play with scroll and it works:
var pos = 500;
$("html,body").animate({ scrollTop: pos }, "slow");
maybe you mean top: 0
$('a#gotop').click(function() {
$("html").animate({ top: 0 }, "slow", function() {
alert('Animation complete.'); });
//return false;
});
from animate docs
.animate( properties, [ duration ], [ easing ], [ callback ] )
properties A map of CSS properties that the animation will move toward.
...
or $(window).scrollTop()
?
$('a#gotop').click(function() {
$("html").animate({ top: $(window).scrollTop() }, "slow", function() {
alert('Animation complete.'); });
//return false;
});