我想单独单击事件。javascript单击事件分隔
所有的body
标签中点击要警惕“表外”,
除了内部postit-table
类的Click事件。
这是我的代码:
HTML
<table class="postit-table">
<tbody>
<tr class="postit-header">
<td>header</td>
</tr>
<tr>
<td><textarea class="postit-content"></textarea></td>
</tr>
</tbody>
</table>
CSS
.postit-table{
width: 200px;
height: 200px;
background-color: yellow;
}
的JavaScript(jQuery的):
$("body").bind('click',':not(".postit-table,.postit-table tbody, .postit-table tr, .postit-table tbody tr td")', function (e) {
alert("clicked outside table!");
});
$(".postit-table").click(function(){
alert("clicked inside table!");
});
的jsfiddle:
不幸的是,如果你运行的小提琴应用程序,它仍然调用外部表的单击事件:(
有人可以帮忙吗?