Sometimes we need our custome CSS trick to create our website more beautiful & attractive. jQuery handles this event perfectly. Today I’m giving a solution that, I try to create a smooth scrolling.

At the header of my website, I create a <a> tag which was trigger to a specific div.

<a herf="#requestdiv"></a>
<div id="#requestdiv"></div>

The above code indicates a <a> tad which refers to a <div> tag.
Now we create the script for smooth scrolling.

<script>
  $('a[href=#requestdiv]').click(function(){
         $('html, body').animate({
         scrollTop: $("#requestdiv").offset().top
      }, 2000);
   });
</script>

I think this small thing will help you. 😊

You're welcome to suggest any article to write!

Leave a Reply

Your email address will not be published. Required fields are marked *