How to check if the URL contains a given string add class on link using jQuery

By toswebdev, 20 December, 2021
How to check if the URL contains a given string add class on link using jQuery
   if (window.location.href.indexOf("user") > 0) {
      $("#block-main-menu ul li:first-child").addClass(
        "menu-item--active-trail"
      );
    }

 

Comments

All comments go through moderation, so your comment won't display immediately.