queue  41
support
Results 1 to 2 of 2

Thread: Buttons not using anchor links

  1. #1
    Junior Member
    Join Date
    Aug 2016
    Posts
    15

    Buttons not using anchor links

    Hi,
    In the about section of the website www.safeguardelectrical.co the buttons See our work and Make an enquiry don't do anything. The button links are #work and #contact, the work section is named work and the contact section named contact.

    (The menus link correctly to these sections as does the enquiry button in the services section.)

    What am I doing wrong with the buttons in the about section?

    Thank you,
    Liz

  2. #2
    Lead Support Ante's Avatar
    Join Date
    Oct 2012
    Posts
    16,930
    Hi,

    please try adding this to Custom JS field in Theme Options panel:
    Code:
    jQuery( function( $ ) {
      
      var $navigation = jQuery( '#the-navigation' ),
      isLoggedIn = jQuery( '#wpadminbar' ).length;
      
      peThemeOffset = isLoggedIn ? $navigation.outerHeight() + jQuery( '#wpadminbar' ).height() : $navigation.outerHeight();
      
      jQuery('a').on( 'click', function( e ) {
        
        var $this = jQuery( this ),
        target = '#section-' + $this.prop( 'hash' ).substring(1);
        
        if ( $this.closest( '.smoothscroll' ).length ) {
          
          return;
          
        }
        
        if ( window.location.href.replace( window.location.hash, '' ) === $this.attr( 'href' ) ) {
          
          e.preventDefault();
          
          jQuery.smoothScroll(0);
          
          return;
          
        }
        
        if (  '' === $this.prop( 'hash' ) || ! jQuery( 'body' ).find( target ).length ) {
          
          return;
          
        }
        
        jQuery.smoothScroll({
          speed: 800,
          offset: -peThemeOffset,
          scrollTarget: target
        });
        
      });
      
    });