Jquery 选中表格中的所有复选框时选中标题复选框
我希望在选中表中的所有复选框时选中标题复选框,如果未选中单个复选框,则应取消选中标题复选框Jquery 选中表格中的所有复选框时选中标题复选框,jquery,html,checkbox,html-table,Jquery,Html,Checkbox,Html Table,我希望在选中表中的所有复选框时选中标题复选框,如果未选中单个复选框,则应取消选中标题复选框 <html> <table id="table" style="height:350px;margin-left:1em;width:700px;"> <!--this is my table header--> <tr style="display:table-row"> <th class="checkbox">
<html>
<table id="table" style="height:350px;margin-left:1em;width:700px;">
<!--this is my table header-->
<tr style="display:table-row">
<th class="checkbox"><input type="checkbox"/></th>
<th class="Name">NAME</th>
<th class="Score">SCORE</th>
<th class="Email">EMAIL</th>
<th class="Empty"></th>
</tr>
<tr>
<!--tabledata-->
<td ><input type="checkbox" /></td>
<td >Vijay Prakash</td>
<td >34</td>
<td >vijay@gmail.com</td>
<td ></td>
</tr>
<tr>
<!--tabledata-->
<td ><input type="checkbox" /></td>
<td >Sashi Pagadala</td>
<td >21</td>
<td >sashi@gmail.com</td>
<td ></td>
</tr>
</table>
<input type="button" id="btnCalculate" value="Calculate"/>
<label>Average:</label>
<label id="lblAverage"></label>
<label>Max:</label>
<label id="lblMax"></label>
</form>
</html>
名称
分数
电子邮件
维杰·普拉卡什
34
vijay@gmail.com
萨西·帕加达拉
21
sashi@gmail.com
平均值:
最大值:
看看这是否是您想要的
使用jquery………@Bharabhushan没问题。。如果您对答案感到满意,请标记为答案。:)我在表外有一个文本框…在其中,用户键入表“名称”列中的某个人名…我们可以突出显示与文本框具有相同值的所有表单元格吗?
$('td input:checkbox').change(function(){
$('th.checkbox :checkbox').prop('checked',$('td input:checkbox:checked').length == $('td input:checkbox').length);
});