Page code
Code in js
/*js part
* Bind batch selected/unselected
* Example
*/
$(function () {
$("#checkall").click(function () {
var stu = $(this).attr("checked");
checkAll (stu);
})
$("input[name='checkbox']").click(function () {
uncheckAll();
})
})
function checkAll(status) {
$("input[name='checkbox']").each(function () {
$(this).attr("checked");
$ (this).attr("checked", status);
})
}
function uncheckAll() {
alert($("input[name='checkbox']: checked").length);
if ($("input[name='checkbox']:checked").length == $("input[name='checkbox']").length) {
$("#checkall").attr("checked",true);
}
else {
$("#checkall").attr("checked", false);
}
}