Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 5 years ago.
Improve this question
I would like to know how to make a link on a navigation menu stay selected when you have clicked on it? A good tutorial or example would be nice:)
I happen to have some computer codes that do exactly this.
a.selected {
background-color:#1F75CC;
color:white;
}
$("a").live('click', function() {
$("a").removeClass("selected");
$(this).addClass("selected");
return false;
});
you can use in this link apycom.com.
i'm a newbie too.and i have used this for my page.
$('a[href="'+window.location.href+'"]').addClasss('currentPage');
This should do the trick. The condition is to have full path.
However, the right way is to generate correct code from the server side.
This works for me
var pathname = window.location.pathname;
$(".ui-accordion-content-active ul li a[href$='" + pathname + "']")