'); $('#back_to_top a').click(function(e){ e.preventDefault(); $('html, body').stop().animate({ scrollTop: $($(this).attr('href')).offset().top }, 1000); }); $('#back_to_top').css({ position:'fixed', right:0, top:'150px' }); $(document).scroll(function(){ if($(document).scrollTop() > 50 && $(window).width() >= 400) { $('#back_to_top:hidden').fadeIn(); } else { $('#back_to_top:visible').fadeOut(); } });