It is an open card and I have a static menu, but I had to add the class active to them so that when a different block color was active

<script type="text/javascript"> jQuery(document).ready(function($) { var url=document.location.href; $.each($("div.left-menu .list-group-item.leftje"),function(){ if(this.href==url){ $(this).addClass('active'); } }); }); </script> 

But I have one problem, the main page is site.ru link. If you click on the main page, then site.ru/index.php?route=common/home turns, then, accordingly, there is no such class, and I also want to make an asset on one block was always included if the link starts with http://tonymoly.cosmos-team.ru/index.php?route=product/ on any other text. Is it possible to do this?

UPD Links of this type

 <a class="list-group-item leftje" href="http://site.ru">Магазин</a> <a class="list-group-item leftje" href="http://site.ru/index.php?route=information/information&information_id=6">Доставка</a> <a class="list-group-item leftje" href="http://site.ru/index.php?route=information/information&information_id=7">Оплата</a> <a class="list-group-item leftje" href="http://site.ru/index.php?route=information/contact">Контакты</a> 

    1 answer 1

    Compare pathname .

     jQuery(document).ready(function($) { var pathname=document.location.pathname; $.each($("div.left-menu .list-group-item.leftje"),function(){ if(this.pathname==pathname){ $(this).addClass('active'); } }); }); 
    • I did this, but then everyone except the main one became active, their ways added to the question - reddyk
    • If you have all the navigation using GET parameters, then do this: jQuery(document).ready(function($) { var search=window.location.search; $.each($("div.left-menu .list-group-item.leftje"),function(){ if(this.search==search){ $(this).addClass('active'); } }); }); - Petr Chalov