可能重複:
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