I have created a menu in my asp.net website and I want the active Menu item in the menu to be highlighted when it is clicked. That is usually the menu is White but when the user choose any of the menu then it should become red. Please find below what I have tried so far:
Jquery:
<head runat="server">
<script type="text/javascript">
$('.thumbnail').click(function (e) {
$('.thumbnail').removeClass('selected');
$(this).addClass('selected');
});
</script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
aspx page:
<div id="nav">
<ul>
<li><a href="Default.aspx" class="thumbnail">Dashboard</a> //I want this
menu option to be Red when in the Dashboard page.
<ul>
<a href="Default.aspx" class="hover">
<li>Servie Details</li>
</a><a href="Dashboard_totalusersDaily.aspx" class="hover">
<li>Subscribers History</li>
</a><a href="WhiteList.aspx" class="hover">
<li>Whitelist </li>
</a>
</ul>
</li>
<li><a href="mnggroup.aspx" class="thumbnail">Subscribers</a> //I want this
Subscrivers Menu Option to be Red when user is in this page
<ul>
<a href="mnggroup.aspx" class="hover">
<li>Group</li>
</a>
<a href="#" class="hover">
<li>Subscribers Chart</li>
</a>
<a href="#" class="hover">
<li>Subscribers Chart by Date </li>
</a>
<a href="#" class="hover">
<li>Inactive Subscribers Chart</li>
</a>
</ul>
</li>
</div>
CSS:
.thumbnail {
display: block;
line-height: 2.5em;
margin-right: 0px;
padding: 8px 14px 8px 14px;
color: #3d3737;
font-weight: bold;
font-size: 0.8em;
text-decoration: none;
}
#nav ul li .selected {
color: #ffffff;
background-color: transparent;
background-image: url(../Img/navaktiv.jpg);
background-repeat: repeat-x;
}
I got this above code idea from this link: how to change menu background color when selected?
After trying this above code all of my menu items remaining white. When I choose any option it is not becoming red. Please help. Thanks in advance.