function smoothscroll(){ $("a[href*='#']:not(.noroll),area[href*='#']:not(.noroll)").not(".list a").click(function(){ $(this).scrollTo(500); return false; }); } jQuery.fn.extend({ scrollTo : function(speed, easing){ if(!$(this)[0].hash || $(this)[0].hash == "#"){ return false; } return this.each(function() { var targetOffset = $($(this)[0].hash).offset().top; $('html,body').animate({scrollTop: targetOffset}, speed, easing); }); } }); $(document).ready(smoothscroll); $(function () { var topBtn = $('.pageTop'); topBtn.hide(); $(window).scroll(function () { if ($(this).scrollTop() > 300) { topBtn.fadeIn(); } else { topBtn.fadeOut(); } }); topBtn.click(function () { $('body,html').animate({ scrollTop: 0 }, 500); return false; }); });