我正在使用jQuery的事件委托向表行添加单击事件。我在该行的第一个td中也有一个复选框。当我点击行中的任何地方时,一切都按预期工作。不过,当我点击复选框时,我不希望事件发挥作用。我试过使用:not()选择器,但也许我错过了一些东西,因为当我单击复选框时,仍然触发事件。如何忽略td内的复选框
HTML
<tr>
<td>
<div class="myCheckbox"><input type="checkbox" name="userName" /></div>
</td>
<td><a href="/go/to/user/profile"></a></td>
<td>more info</td>
<td>more info</td>
<td>more info</td>
</tr>
jQuery的
$('table tr:not(':checkbox')').on('click', 'td', function(event) {
// Do something
});
我可以帮助解决我正在尝试做的事吗?
[父事件处理程序的执行防止]的可能重复(http://stackoverflow.com/questions/1398582/prevent-execution-of-parent-event-handler) – 2012-07-26 21:22:22