Rajasekar Rajasekar - 1 year ago 101
CSS Question

What is the opposite of CLICK event?

I had a list

where the content inside li should get bold when it is clicked. For that i used the following code


<ul class="tabs">
<li><a href="#tab1" style="padding-left:5px;">All Sectors</a></li>
<li><a href="#tab2">Information Technology</a></li>
<li><a href="#tab3">Manufacturing</a></li>
<li style="border-right:none;"><a href="#tab4">Services</a></li>


$(document).ready(function() {
$(".tabs li a").click(
function() { $(this).css({ "font-weight" : "bold" }); }



But When the list item is clicked it gets bold. I want the list item to get back to normal when the other list item is clicked. I am not able to find the correct event. Your help will be greatly appreciated.

Answer Source

It would actually be easier to do this at the <li> level rather than the <a> since it would have the same bolding effect (and direct access to .siblings()), like this:

$(".tabs li").click(function() {

Then you can use CSS for the class like this:

.boldClass { font-weight: bold; }

Instead of .addClass("boldClass") you could use .toggleClass("boldClass") if you want a click on an already-bold link to un-bold it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download