Add css id to li link dependant upon keyword in url
Hi - I've just started learning jquery and have been trying to use this code which I found on this forum.
I want to detect some text (addClients) in the url and add an css id to a list item with the class m1 (li class="m1") - so I get (li class="m1" id="expanded"):
This is what I have so far (which is not working)
-
$(function() {
$(document).ready(function() {
var url = location.pathname;
if(url.indexOf('addClients') > -1) {
$("li.m1").attr("id","expanded");
}
});
I'm wondering if I need to specify the full path the the li as it is contained with a few divs and also some nested ul tags.
Any help appreciated
