<table>
<tr><td>First Row</td><td>2 Row</td><td>1 last</td></tr>
<tr><td>Middle Row</td><td>2 Row</td><td>2 last</td></tr>
<tr><td>Last Row</td><td>2 Row</td><td>3 last</td></tr>
</table>
$('tr').each(function(index) {
$("td:last").css({backgroundColor: 'yellow', fontWeight: 'bolder'});
});
LIVE: http://jsfiddle.net/DxVG5/1/
why this working only for 3 last, but on 1 last and 2 last no? how can i fix it?
You need to add the context of the td, you’re already in a for loop so the ‘this’ variable can be used. In this context ‘this’ is equal to the tr you’re currently iterating on.