styling current page link
I'm trying to apply a style to the menu link that matches the current page. Here's what I have...
- <script>
$(document).ready(function(){
var str = $(location).attr('href');
$('#innermenu li a').each(function() {
if (str === this.href) {
$("li").addClass("hilite");
}
});
})
</script>
... but it fails to add the class to the li that contains the href that matches the location.
What am I missing?
Is there a better way to do this?