<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script>
$(document).ready(function (){
$("#selectall").bind("click", function (){
$('.check').attr('checked', this.checked);
});
$(".check").bind("click", function(){
if($(".check").length==$(".check.checked").length) {
$("#selectall").attr("checked", "checked");
} else {
$("#selectall").removeattr("checked");
}
});
});
</script>
</head>
<body>
<h2> My Example </h2>
<table border="1">
<tr>
<th> <input type="checkbox" id="selectall"/></th>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td> <input type="checkbox" class="check"/></td>
<td> Name1</td>
<td> 10000</td>
</tr>
<tr>
<td> <input type="checkbox" class="check"/></td>
<td> Name2</td>
<td> 10000</td>
</tr>
<tr>
<td> <input type="checkbox" class="check"/></td>
<td> Name3</td>
<td> 10000</td>
</tr>
<tr>
<td> <input type="checkbox" class="check"/></td>
<td> Name4</td>
<td> 10000</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script>
$(document).ready(function (){
$("#selectall").bind("click", function (){
$('.check').attr('checked', this.checked);
});
$(".check").bind("click", function(){
if($(".check").length==$(".check.checked").length) {
$("#selectall").attr("checked", "checked");
} else {
$("#selectall").removeattr("checked");
}
});
});
</script>
</head>
<body>
<h2> My Example </h2>
<table border="1">
<tr>
<th> <input type="checkbox" id="selectall"/></th>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td> <input type="checkbox" class="check"/></td>
<td> Name1</td>
<td> 10000</td>
</tr>
<tr>
<td> <input type="checkbox" class="check"/></td>
<td> Name2</td>
<td> 10000</td>
</tr>
<tr>
<td> <input type="checkbox" class="check"/></td>
<td> Name3</td>
<td> 10000</td>
</tr>
<tr>
<td> <input type="checkbox" class="check"/></td>
<td> Name4</td>
<td> 10000</td>
</tr>
</table>
</body>
</html>
1 comments
Try this one, select all checkboxes in a row after checked checkbox, http://justwebcode.blogspot.com/2017/07/select-all-checkboxes-in-a-row-following-checked-checkbox.html