[jQuery] Re: Match the filename to highlight current link on page

2008-10-13 Thread Karl Swedberg
You could try something like this: function filterPath(pathString) { return pathString.replace(/^\//,'').replace(/\/(index\.\w{3,4})? $/,'') } $('a').filter(function() { return filterPath(this.pathname) == filterPath(location.pathname); }).addClass('active'); Then, style an active class

[jQuery] Re: Match the filename to highlight current link on page

2008-10-13 Thread suntrop
No one can help? I tought with jquery one can select everything!

[jQuery] Re: Match the filename to highlight current link on page

2008-10-08 Thread suntrop
Hi Adrian, thanks for your help but I can't follow you. I have no directories to split - but if, this is a good solution. I think the problem occurs here: $('#navigation [EMAIL PROTECTED]"' + path + '"]') The @href finds all elements which contains the path (filename). And if filename 1 is pota

[jQuery] Re: Match the filename to highlight current link on page

2008-10-08 Thread suntrop
Hi Adrian, thanks for your help but I can't follow you. I have no directories to split - but if, this is a good solution. I think the problem occurs here: $('#navigation [EMAIL PROTECTED]"' + path + '"]') The @href finds all elements which contains the path (filename). And if filename 1 is pota

[jQuery] Re: Match the filename to highlight current link on page

2008-10-06 Thread Adrian Lynch
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 a