私はjQueryの初心者です。これは以前に尋ねられたことがあることは知っていますが、HTMLでそれを行う適切な方法がわかりません。
<fieldset>
<legend>ABC</legend>
<label class="selectAllButton"><input type="checkbox" onclick="SelectAll(this)" />(select all)</label><br />
<table>
<tr>
<td>
<input id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_chkItem_0" type="checkbox" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl00$chkItem" /><label for="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_chkItem_0">Discs</label>
<input type="hidden" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl00$pgNos" id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_pgNos_0" value="9;71;72;108;109" />
<input type="submit" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl00$btnXRefs" value="x-refs" id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_btnXRefs_0" class="xRefButton" />
</td>
</tr>
<tr>
<td>
<input id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_chkItem_1" type="checkbox" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl01$chkItem" /><label for="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_chkItem_1">Drums</label>
<input type="hidden" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl01$pgNos" id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_pgNos_1" value="73" />
<input type="submit" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl01$btnXRefs" value="x-refs" id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_btnXRefs_1" class="xRefButton" />
</td>
</tr>
<tr>
<td>
<input id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_chkItem_2" type="checkbox" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl02$chkItem" /><label for="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_chkItem_2">Pads</label>
<input type="hidden" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl02$pgNos" id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_pgNos_2" value="70" />
<input type="submit" name="ctl00$MainContentPlaceHolder$CategoryRepeater$ctl00$ItemRepeater$ctl02$btnXRefs" value="x-refs" id="MainContentPlaceHolder_CategoryRepeater_ItemRepeater_0_btnXRefs_2" class="xRefButton" />
</td>
</tr>
</table>
</fieldset>
これをクリックしてほしい:
<label class="selectAllButton"><input type="checkbox" onclick="SelectAll(this)" />(select all)</label><br />
また、下のすべてのチェックボックスをtable
オンまたはオフにします。
私は試した :
// selects all the items in same category
function SelectAll()
{
$(arguments[0]).siblings('table:eq(0)').find(':checkbox').attr('checked', arguments[0].checked);
}
しかし、それは機能しませんでした。