Hello Developers,

i have a link structure like this on my website...

index.php - homepage
index.php?section=  - other pages

here is a piece of code that i wrote to change the colour of the active link...

$(function(){
     var path = location.pathname.substring(1);
     if ( path )
          $('#nav ul#navigation li a[href$="' + path + '"]').attr('class', 'selected');
});

but this doesn't take into account of php link structures, only flat file links. How would i get this working for links like "index.php?section=" aswell as the basic links like "index.php"?.

Kind Regards,
Nathaniel Blackburn

Use location.search to get the query from the url.

Like this:

$(function(){
     var path = location.pathname.substring(1);
     if ( location.search )
          path += location.search;
     if ( path )
          $('#nav ul#navigation li a[href$="' + path + '"]').attr('class', 'selected');
});

Hope it helps.

Awesome thanks ill be sure to give this a go shortly.