JSFiddle - React, Tailwind, and code Playground

by rajaadil

HTML

<div style="height:1200px;">scroll all the way to the bottom</div>

<div id="Anchor">Anchor</div>

<div style="height:1200px;"></div>

<div class="scrollToCal" data-idtopass="Anchor">click me to go to Anchor</div>

JavaScript

jQuery(document).ready(function($) {

    $('.scrollToCal').click(function() {
      
        $('html, body').animate({
            scrollTop: $('#' + $(this).data('idtopass')).offset().top - 5
        }, 'slow');
        return false;
    });

});