Hello, I have implemented a jQuery script to change the color of a menu item when it is selected:
.selected{
background-color: red;
}
$("#nav-container>li").click(function(){
$(this).addClass('selected')
.siblings()
.removeClass('selected');
});
The corresponding HTML code is as follows:
<ul id="nav-container">
<li id="welcome">
<a href="/" >Welcome</a>
</li>
<li id="find">
<a href="/find">Find</a>
</li>
<li id="talk">
<a href="/talk">Talk</a>
</li>
<li id="events">
<a href="/event">Events</a>
</li>
</ul>
The issue I am facing is that once the page is refreshed or navigated to a new page, the color for the selected item is not retained. Can anyone provide any insights on what I may be missing in my implementation? Thank you.