w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
wordpress class 'current-menu-item' not showing in nav menu in some pages when we are on the current page

Using jQuery solwing these problem : Please write these jQuery script and check

<script>
jQuery(function(){

  var activeurl = window.location;
 
if(jQuery('a[href="'+activeurl+'"]').parent().parent().parent().parent().parent().hasClass('menuitem'))
  {
    
jQuery('a[href="'+activeurl+'"]').parent().parent().parent().children('h3').children('a').addClass('current-menu-item');
    
jQuery('a[href="'+activeurl+'"]').parent().parent().addClass('current-menu-item');
  }
  else
  {
    
jQuery('a[href="'+activeurl+'"]').parent().parent().parent().children('a').addClass('current-menu-item');
     jQuery('a[href="'+activeurl+'"]').addClass('current-menu-item');
    
jQuery('a[href="'+activeurl+'"]').parent().parent().addClass('current-menu-item');
  }


});
</script>




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.