Smooth Scrolling on A Name tags in one page web site

JQuery Smooth Scrolling on A Name tags in one page web site. You can add the link to navigate between DIV sections in single page web site.

Link :

<li data-slide="4"><a href="index.html#slide4" >About</a></li>

Target ( on same page) :

<div class="slide" id="slide4" data-slide="4" data-stellar-background-ratio="0.5">
</div>

Code ( on header section ) :
 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script>
$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
});
</script>