1 //scroll to id
2 var $root = $('html, body');
3 $('a[href^="#"]').click(function () {
4 var href = $.attr(this, 'href');
5 $root.animate({
6 scrollTop: $(href).offset().top
7 }, 500, function () {
8 window.location.hash = href;
9 });
10
11 return false;
12 });