I have a scroll back to top button that brings the user back to the top of the page with a smooth glide. It is working in Firefox but not Chrome:
$('a#scroll-to-top').click(function() {
$('html').animate({
scrollTop: 0
}, 500);
return false;
});
<a href="#" id="scroll-to-top">Up Top</a>
How to get this to work in Chrome?
I have a scroll back to top button that brings the user back to the top of the page with a smooth glide. It is working in Firefox but not Chrome:
$('a#scroll-to-top').click(function() {
$('html').animate({
scrollTop: 0
}, 500);
return false;
});
<a href="#" id="scroll-to-top">Up Top</a>
How to get this to work in Chrome?
Share Improve this question asked May 14, 2012 at 22:32 user967451user967451 2- possible duplicate of How do I scroll to the top of the page with jQuery? – j08691 Commented May 14, 2012 at 22:39
- @j08691 not quite the same question – CharlesB Commented May 18, 2012 at 8:23
2 Answers
Reset to default 4You would like to use this code:
$('a#scroll-to-top').click(function() {
$('html, body').animate({
scrollTop: 0
}, 500);
return false;
});
Here is example
Just use body instead of html like below:
$('a#scroll-to-top').click(function() {
$('body').animate({
scrollTop: 0
}, 500);
return false;
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745093968a4610861.html
评论列表(0条)