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