.scrollTop()
$(function() { $('a[href^="#"]').click(function() { $('html,body').scrollTop($($(this).attr('href')).offset().top); return false; });});
.scrollTop()to scroll the viewport based on the element offset: http://jsfiddle.net/tovic/kw7LD/7/show/