EduardET

Fix wodpress anchor links

Dec 14th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. ( function( $ ) {
  3.     $( document ).ready( function() {
  4.         var menuLinks = $( "#top-menu li" );
  5.         menuLinks.each( function() {
  6.             if ( !$( this ).hasClass( "home-item" ) ) {
  7.                 if ( $( this ).hasClass( "hash-link" ) || $( this ).hasClass( 'hash-container' ) ) {
  8.                     $( this ).removeClass( "current-menu-ancestor current-menu-parent current-menu-item" );
  9.                 }
  10.             }
  11.             var subMenuLink = $( this ).find( ".sub-menu li a" );
  12.             subMenuLink.click( function() {
  13.                 menuLinks.removeClass( "current-menu-ancestor current-menu-parent current-menu-item" );
  14.                 $( this ).parent().parent().parent().addClass( "current-menu-ancestor current-menu-parent" );
  15.                 $( this ).parent().addClass( "current-menu-item" );
  16.             } )
  17.         } )
  18.     } );
  19. } )( jQuery );
  20. </script>
Advertisement
Add Comment
Please, Sign In to add comment