Set active link based on URL

后端 未结 6 1894
猫巷女王i
猫巷女王i 2021-01-29 05:58

If the URL ends: ?style=product I want to add a class of active to the li with the class of product

HTML:

<         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-29 06:12

    First up you'll need a javascript function similar to the one posted here, this will allow you grab the style variable from the querystring.

    Once you have that try something like:

    var style = getParameterByName('style');
    $('li.' + style).addClass('active'); 
    

提交回复
热议问题