如何在下面我创建的jQuery中排除特定的TD(比如第一个)不参与行事件?
```javascript $('tr').on('click', function(){ $(this).addClass('selected'); }); ```
我需要为我的
```javascript $('tr').on('click', function(){ $(this).addClass('selected'); }); ```
jQuery("#list tbody tr").click(function(){
alert('click this');
//some code here
});
jQuery("#list tbody tr td.exclude").click(function(){
alert('click not that');
//some code here
});
td { border: 1px solid black; padding: 5px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="list">
<tr>
<td class="exclude">first</td>
<td>second</td>
<td>third</td>
</tr>
<tr>
<td class="exclude">first</td>
<td>second</td>
<td>third</td>
</tr>
</table>
row
设置一个事件,但要排除所有类名为exclude
的TD
元素,这可行吗?