• About us and the Itinerary nav menu are linked to the about us section and the tour Itinerary section at the bottom of the page using the anchor tag, however, on every second click it scrolls to the top rather than jumping on to its respective section. I have used this code to resolve it but it didn’t work. How can I resolve this issue?

    jQuery(document).ready(function(){
    jQuery(function($) {
    // Clicking a link with # in href
    $(‘a[href*=”#”]:not([href=”#”]):not([href*=”#elementor-action”])’).click(function(e) {
    e.stopImmediatePropagation();
    var target = $(this.hash);
    if ($(“body”).hasClass(“admin-bar”)) {
    $(‘html,body’).stop().animate({
    scrollTop: target.offset().top – ( 112 ) }, ‘linear’);
    } else {
    $(‘html,body’).stop().animate({
    scrollTop: target.offset().top – ( 80 ) }, ‘linear’);
    }
    });
    // Loading a url with # in it
    if (location.hash){
    var id = $(location.hash);
    }
    $(window).on(‘load’, function() {
    if (location.hash){
    if ($(“body”).hasClass(“admin-bar”)) {
    $(‘html,body’).animate({scrollTop: id.offset().top – ( 112 ) }, ‘linear’);
    }
    else {
    $(‘html,body’).animate({scrollTop: id.offset().top – ( 80 )}, ‘linear’);
    }
    };
    });
    });
    });`

    The page I need help with: [log in to see the link]

  • The topic ‘Anchor Tag Scroll to the top.’ is closed to new replies.