Smooth scrolling when clicking an anchor link



1. Add below coder in script


<script src="js/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>





2. Add below coder in HTML


<a class="" href="#1">See ore</a>


<div name="1"  class="onerow"> </div

No comments:

Powered by Blogger.