Easy Scroll To Everywhere

17 Jun 2013

Getting started

Add javascript to your html page


<script language="javascript">  
  $(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/>

Create a link like this


<a href="http://example/#tab1">Go to tab1</a>

create a tag which should equal ‘tab1’


<div id="tab1"> Tab1 </div>

Now you can try it ! Then you will love it !