Reputation: 211
I have 5 links on page, when i click on each link it will change the color but as soon as ma=ove my cursor and place on other area of page, the focus on active link gets disappear. so I am not able to show the current link state. please tell me how to fix
Upvotes: 1
Views: 2662
Reputation: 4854
Html
<tr>
<td>
<a href="#" class="linkbold">Basic2</a>
</td>
</tr>
<tr>
<td>
<a href="#" class="linkbold">Basic3</a>
</td>
</tr>
<tr>
<td>
<a href="#" class="linkbold">Basic4</a>
</td>
</tr>
Css
.linkbold{ color:#0066FF; font-family:Tahoma; font-size:11px; text-decoration:none; font-weight:bold !important; }
.active { color: red; } // define any color for active class
// you can use css shorthand for font property
.linkbold { font: bold 11px Tahoma, sans-serif; color:#0066FF; }
If you want to know more about css shorthand
Jquery
$('a.linkbold').on('click', function(){
$('a.linkbold').removeClass('active'); // remove any active class
$(this).addClass('active'); // and then add active class for clicked element.
});
Upvotes: 3
Reputation: 1
<html>
<head>
<style type="text/css">
a:link {color:blue;}
a:visited {color:red;}
a:hover {color:green;}
</style>
</head>
<body>
<a href="#">first</a>
<br/>
<a href="#">second</a>
</body>
</html>
Upvotes: -2