jQuery(document).ready(function($) { //show button if scrolling $(window).scroll(function() { if($(this).scrollTop() > 300) { $('.scrltop_button').fadeIn(100); } else { $('.scrltop_button').fadeOut(100); } }); //Go to top $('.scrltop_button').click(function() { $('body,html').animate({scrollTop:0},600); return false; }); });