[英]How to check/uncheck a checkbox while clicking a table row
我需要選中/取消選中表主體下一行中存在的復選框(當單擊鏈接以外的行中的任何位置時)。 我試圖通過使用jQuery的道具使其工作,但某些工作無法正常進行。
我有一個如下表結構:
<table id="anywhere_click">
<thead>
<tr>
<th><input type="checkbox" onclick="selectAll('myDataID[]');" /></th>
<th>Title</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" name="myDataID[]" value="1" /></td>
<td>Stackoverflow</td>
<td>Some text here....</td>
</tr>
<tr>
<td><input type="checkbox" name="myDataID[]" value="2" /></td>
<td>Google</td>
<td>
<a href="aaa.html">This is a Link</a><br />
Some text here....<br />
<img src="something.jpg" />
</td>
</tr>
<tr>
<td><input type="checkbox" name="myDataID[]" value="3" /></td>
<td>test</td>
<td>Some text here....</td>
</tr>
</tbody>
</table>
$('#anywhere_click tbody tr').click(function (e) {
if(!$(e.target).is('#anywhere_click td input:checkbox'))
$(this).find('input:checkbox').trigger('click');
});
$('#anywhere_click tr a').click(function (e) {
e.stopPropagation();
});
如果您檢查了網站的加載時間。
您必須在<td><input type="checkbox" name="myDataID[]" value="3" /></td>
的標簽<td><input type="checkbox" name="myDataID[]" value="3" /></td>
。
<td><input type="checkbox" name="myDataID[]" value="3" checked /></td>
使用您要檢查和取消檢查的按鈕。
信息: 信息
和示例: 選中並取消選中按鈕的前導
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.