HTML <table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
<td>row 2, cell 3</td>
</tr>
</table>
JS $(document).ready(function() {
$("tr").find("td").eq(2).click(function(){
alert('hi');
});
$("tr").find("td").not().eq(2).click(function(){
alert('hi2');
});
}); |
What I'm trying to do here is bind a different click event for the every 3rd <td>
of each row and every other <td>
different click function. 1st function works but how can I bind event for the <td>
's which are not the 3rd ones?
Pass the selector to the not
method.
$("tr").find("td").not(':eq(2)').click(function(){
alert('hi2');
}); |