可能重复:
jQuery - on() function when a div is clicked, but not when a child of that div is clicked在点击TD,文本框被点击
$(oTrPlanning).prev().children('td').each(function() {
this.onclick = setCountClick;
});
在TD setCountClick()
的点击被调用,但TD还包含了Textbox
:
<td>
<input class="Input-InlineFilter" id="TextFirst" type="text" value="">
</td>
因此,当我开始在Textbox
上输入内容时,setCountClick()
再次被调用。 单击TD时,我想调用setCountClick()
,但不是Textbox
。
哇喔哇。你为什么要这样绑定'click'?为什么不能'$(oTrPlanning).prev()。on('click','td',setCountClick)'? – Mathletics
我只是要刺穿这个,但会onclick =“返回false;”在文本框中防止? – Bender
@Mathletics将做到这一点 – Yogesh