Team:Lethbridge Canada/back to top script

From 2014hs.igem.org

(Difference between revisions)
(Created page with "jQuery(document).ready(function() { var offset = 220; var duration = 500; jQuery(window).scroll(function() { if (jQuery(this).scrollTop() > offset) { jQuer...")
 
Line 1: Line 1:
jQuery(document).ready(function() {
jQuery(document).ready(function() {
var offset = 220;
var offset = 220;
-
var duration = 500;
+
var duration = 100;
jQuery(window).scroll(function() {
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > offset) {
if (jQuery(this).scrollTop() > offset) {

Latest revision as of 12:20, 20 June 2014

jQuery(document).ready(function() { var offset = 220; var duration = 100; jQuery(window).scroll(function() { if (jQuery(this).scrollTop() > offset) { jQuery('.back-to-top').fadeIn(duration); } else { jQuery('.back-to-top').fadeOut(duration); } });

jQuery('.back-to-top').click(function(event) { event.preventDefault(); jQuery('html, body').animate({scrollTop: 0}, duration); return false; }) });