2016-07-05 70 views
2

我正在處理像這樣的多電話亭http://jsfiddle.net/bDvkQ/1038/多點觸控功能上的點擊功能

我加場 「選擇/取消所有」,並補充類 「selectAllBox」 使用此代碼:

$("label[for='Items_option_1']").addClass("selctAllBox"); 
$("label[for='Items_option_1']").parent().addClass("selctAllBox") 

結果:

<li tabindex="-1" class="k-item selctAllBox" role="option" unselectable="on"> 
<input name="Items_option_1" type="checkbox" value="1">&nbsp; 
<label class="selctAllBox" for="Items_option_1">Select/Deselect All</label> 
</li> 

enter image description here

我想,如果我選擇「全選/全部取消」複選框,所有複選框都被取消選中。我已經有一個功能可以做到這一點,但我現在無法弄清楚如何調用這個函數。我試圖做這樣的,但什麼也沒有發生:

$("label[for='Items_option_1']").parent().click(deselectSelectAll); 

$("input[name="Items_option_1"]:checkbox").click(deselectSelectAll); 

我在做什麼錯?

+0

嘗試'$( '輸入[名稱= 「Items_option_1」]')發生變化(deselectSelectAll);' – exabyssus

回答

2

如果功能正常工作,

可以稱之爲selctAllBox類的onClick。

代碼是這樣的:

$(".selctAllBox").click(deselectSelectAll); 
+0

我試過,很好,但沒有任何反應我真不」。 t知道我在做什麼錯 – socramm

-1

我發現了這個問題。

這是解決方案:

+0

換句話說,做@Ygalbel昨天說的話。 – CompanyDroneFromSector7G

+1

是啊我標記他的答案,因爲它是正確的。但沒有'$(document).ready(function(){...}'不適合我 – socramm