Extract the href and then split it into it's various sections

var href  = some selector;

hrefSections = href.split("/");

If there are no query string parameters you have the file name in the
last array element:

var fileName = hrefSections[hrefSections.length - 1];

Now do your other selector and you can compare the whole file name and
not just the end.

Adrian

On Oct 6, 4:46 pm, suntrop <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I've following code to highlight the current link in my menu:
> var path = location.pathname.substring(1);
> if (path != '') {
>         $('#navigation [EMAIL PROTECTED]"' + path + 
> '"]').css('color','#c03');} else {
>
>         $('#navigation [EMAIL PROTECTED]"/"]').css('color','#c03');
>
> }
>
> But some files/pages have similar names like:
> potatoes.html
> fried-potatoes.html
> The second page highlights the first link (potatoes.html) as well.
> What's wrong of course.
>
> How can I make this bulletproof? Is it possible only to match the
> exact filename?
>
> I would be really glad if someone can help!
>
> Regards
> suntrop

Reply via email to