I've been experimenting with keeping the color of a link when clicked, not just while the mouse is over it (so that if the mouse moves away from the link, the color will stay).
For example, on this website, when you click on "Ask a question," the color remains on the tab.
Below is the code snippet I have been working on:
HTML
<ul id="parentExample" style="display: block;">
<asp:Repeater runat="server" ID="uiMenuList">
<ItemTemplate>
<li id="childExample">
<a id="uiMenuText" href="http://www.google.com" target="_blank" runat="server">First Menu</a>
<a id="uiMenuText" href="http://www.google.com" target="_blank" runat="server">Second Menu</a>
<a id="uiMenuText" href="http://www.google.com" target="_blank" runat="server">Third Menu</a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
JavaScript
$(document.ready(function() {
var $h3s = $('li').click(function() {
$h3s.removeClass('active');
$(this).addClass('active');
});
}));
CSS
.active {
background: none;
color: #FFC000;
border: 0px;
margin-top: -3px;
margin-right: auto;
margin-left: auto;
}
#parentExample li#childExample a {
background: none;
color: black;
border: 0px;
margin-top: -3px;
margin-right: auto;
margin-left: auto;
}
#parentExample li#childExample a:hover {
background: none;
color: red;
border: 0px;
margin-top: -3px;
margin-right: auto;
margin-left: auto;
}
#parentExample li#childExample a:active {
background: none;
color: #FFC000;
border: 0px;
margin-top: -3px;
margin-right: auto;
margin-left: auto;
}
#parentExample li#childExample a:selected {
background: none;
color: #FFC000;
border: 0px;
margin-top: -3px;
margin-right: auto;
margin-left: auto;
}
Check out the code sample in action: JS Fiddle
Any assistance would be greatly appreciated
Thank you