我有一個形成一組這樣的元素:
<input type="checkbox" name="chk[140]">
<input type="hidden" value="3" name="ctcount[140]">
<input type="hidden" value="Apples" name="catname[140]">
<input type="checkbox" name="chk[142]">
<input type="hidden" value="20" name="ctcount[142]">
<input type="hidden" value="Bananas" name="catname[142]">
<input type="checkbox" name="chk[144]">
<input type="hidden" value="200" name="ctcount[144]">
<input type="hidden" value="Strawberries" name="catname[144]">
<input type="checkbox" name="chk[145]">
<input type="hidden" value="0" name="ctcount[145]">
<input type="hidden" value="Carrots" name="catname[145]">
當用戶點擊一個按鈕,我想Javascript來:
1. Loop through all the checkboxes
2. For all the checked checkboxes,
2a. Get ctcount value
2b. Get catname value
2c. If ctcount value > 50, alert a message saying "Unable to add item
as max limit for 'catname' has reached.
2d. Break the loop after it encountered first ctcount value that is
greater than 50.
我是新來JQuery..have下面的代碼至今:
VAR checklimit = 50; (函數(i){alert(this.value); });
如何使用JQuery執行此操作?
感謝
你有什麼企圖這麼遠嗎? – 2010-06-07 21:58:30