Example: http://jsfiddle.net/patrick_dw/NYQnP/2/
$('ul > li a[href$=' + window.location.pathname + ']').css('font-weight','bold');
Or maybe better like this, which makes exact matching of both attributes pathname:
$('ul > li a[href]').filter(function() {
return this.href.pathname === window.location.pathname;
).css('font-weight','bold');
If you use the full domain in href, you can change it to:
return this.href === window.location;
source
share