2014-01-22 29 views
0

的INPUT我有以下的HTML中調用從數據表jQuery的功能插件在點擊表頭單元格的列進行排序:製作TD可以點擊的,裏面不

<th class="sorting" role="columnheader" tabindex="0" aria-controls="jobBonusSummary" rowspan="1" colspan="1" style="width: 67px;" aria-label="Name: activate to sort column ascending"> 
<span class="filter_column filter_text"> 
<input type="text" rel="1" value="Name" class="text_filter search_init"> 
</span></th> 

我個是可以點擊的,我想要使跨度或INPUT不可點擊(以工作爲準)!現在,如果我點擊INPUT例如,它會對列進行排序,除非點擊INPUT周圍的區域,否則我什麼也不做。

關於如何做到這一點的任何想法?

+0

將您的jQuery代碼在這裏。 –

回答

1

由於事件在dom樹中冒泡,因此您在輸入字段中的點擊最終會到達周圍。您需要手動停止傳播以防止這種情況發生。

$("input").on("click", function(e) { 
    e.stopPropagation(); 
    // Here you can do additional stuff, which in your case might not be needed 
}); 

the jquery docs

+0

輝煌,謝謝! – NotAnotherCliche

+0

不客氣;) – Christoph