$(function(){ var top = $("#to-top"); var top2 = $("#to-top2"); var top3 = $("#to-top3"); $(window).scroll(function () { if( $(this).scrollTop() > 200 ) { $(top).fadeIn(); $(top2).fadeIn(1000); $(top3).slideDown(); } else { $(top).fadeOut(); $(top2).fadeOut(1000); $(top3).slideUp(); } }); $(top).click(function(){ $("html, body").animate({scrollTop:0}, "fast"); return false; }); $(top2).click(function(){ $("html, body").animate({scrollTop:0}, 500); return false; }); $(top3).click(function(){ $("html, body").animate({scrollTop:0}, 1000); return false; }); });