I’m trying to add to my selected li the proper class if the li’s selected html text match with the retrived url substring. To give an example
I have the following list
<ul>
<li><a href="">test</a></li>
<li><a href="">test2</a></li>
<li><a href="">test3</a></li>
</ul>
If I click on test2 than a get parameter going to be passed and my url would look as it follows
localhost/page/test2
and after the second li should get selected class.
What I tried but it’s not working http://jsfiddle.net/lgtsfiddler/ZjNsv/3/
You need to check each link in the UL against the variable you’re looking for:
Here’s a working fiddle: http://jsfiddle.net/ZjNsv/8/