Reputation: 196539
What is the best way to make a table row bold using jQuery? Do I have to loop through each td ? If there a better way to set a table row bold all at once? The tr has a class associated with it (to be able to reference).
Upvotes: 0
Views: 1720
Reputation: 1959
You could do something like this:
<table>
<tr>
<td>one</td>
<td>two</td>
</tr>
<tr>
<td>three</td>
<td>four</td>
</tr>
</table>
.boldme {
font-weight: bold;
}
$("tr").click(function() {
$(this).toggleClass("boldme");
});
Here is the jsFiddle.
Upvotes: 1
Reputation: 2095
This will bold the font when you click on a table row
$('tr').click(function(e){
$(this).css("font-weight","bold");
e.stopPropagation();
});
here's a demo http://jsfiddle.net/Ctz3X/
Hope that helps,
Upvotes: 1