我试着用这个在表格的每一行上设置点击事件。
这是表:
<table border='1px'>
<tr>
<td class='td'>first row frist column</td>
<td>first row second column</td>
</tr>
<tr>
<td class='td'>second row frist column</td>
<td>second row second column</td>
</tr>
<tr>
<td class='td'>third row frist column</td>
<td>third row second column</td>
</tr>
</table>
这是简单的 jQuery:-
$('table tbody tr td:nth-child(1)').live('click',function(){
alert($(this).text());
})
有了这个,我点击第一列的任何一个,然后在它的警报中我想取消设置表第一行列的点击事件。
我该怎么做。
最佳答案
试试这个,DEMO http://jsfiddle.net/yeyene/CGbXP/4/
给所有列一个类col+number
。然后使用...
var i = 1;
$('td').each(function(){
$(this).addClass('col'+i);
i = i+1;
});
$('table').find("td:not(.col4)").on('click',function(){
alert($(this).text());
})
关于jquery - 如何删除表格第一行的点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17875242/