jQuery.fn.Autoscroll = function(sel) { $('html,body').animate( {scrollTop: $(sel).offset().top},500 ); }