Reputation: 21
I've build a website for my resume with jQuery for some scroll-based events and animations. The problem is the "Go to top" arrow works fine on Chrome (PC) and Mobile Safari but doesn't seem to work on Firefox.
//arrow up show/hide function
$(document).on("scroll", function(){
"use strict";
if($(document).scrollTop() > 500){
$(".arrow-up").addClass("arrow-up-clicked");
} else {
$(".arrow-up").removeClass("arrow-up-clicked");
}
});
//arrow up on click event
$(".arrow-up").on("click", function() {
"use strict";
$("body").animate({
scrollTop: 0
}, "300", "swing");
});
Upvotes: 1
Views: 1582
Reputation: 4397
Try with this..
$('.arrow-up').click(function(){
$('html, body').animate({scrollTop : 0},300);
return false;
});
Upvotes: 1