Reputation: 5824
this is my html code
<table id='code'>
<tr>
<td>data1</td>
<td>data2</td>
<td>data3</td>
<td class='action'>data4</td>
</tr>
<tr>
<td>data1</td>
<td>data2</td>
<td>data3</td>
<td class='action'>data4</td>
</tr>
<tr>
<td>data1</td>
<td>data2</td>
<td>data3</td>
<td class='action'>data4</td>
</tr>
jquery code is.
$('#code tr td').on('click',function(){
alert($(this).html());
});
this is my jquery code this is working. this fire click event on all td tags.
but I want click event fire only first three td
not in td.action
means last td
.
Upvotes: 2
Views: 509
Reputation: 10378
$('#code tr').on("click","td:not('.action')",function(){
alert($(this).html());
});
Upvotes: 2
Reputation: 388326
You can use :not() or .not() to ignore a set of elements matching the selector
$('#code tr td:not(.action)').on('click',function(){
alert($(this).html());
});
Demo: Fiddle
or
$('#code tr td').not('.action').on('click',function(){
alert($(this).html());
});
Demo: Fiddle
Upvotes: 4