add active class to li from page url

后端 未结 4 990
终归单人心
终归单人心 2020-12-11 13:10

I am using the following to get the active page url:



        
4条回答
  •  死守一世寂寞
    2020-12-11 13:50

    I am not sure if you want solution in Javascript. Here my suggestion Your Html code

      
    

    Javascript Code

    url = 'http://www.domain-nane.com/index.php?option=com_content&view=article&id=6&Itemid=111';
       //  url = '';
    var urlRegex =/Itemid=([0-9]+)/i;
    var Itemid = url.match(urlRegex)[1];
    // alert(Itemid);
    
    var nodes = document.getElementById('navigation').childNodes;
    var lis;
    for(i=0; i

    Running Example http://jsfiddle.net/xdsUm/3/

提交回复
热议问题