wordpress-zerro/js/main.js
2023-12-09 16:39:41 +08:00

23 lines
525 B
JavaScript

var SCROLL_SPEED = 400;
var ready = function(callback) {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
}
ready(function() {
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > 50) {
jQuery('#back-to-top').fadeIn();
} else {
jQuery('#back-to-top').fadeOut();
}
});
jQuery('#back-to-top').click(function() {
jQuery('body,html').animate({
scrollTop: 0
}, SCROLL_SPEED);
return false;
});
});