Check uncheck all check boxes on an asp.net web form using jquery.
On click of the link it behaves like a toggle button and changes its text also it check and un check all check boxes on the asp.net page
Asp.net Code
<a href=”#” id=”lnkAll”>Check all</a>
JQuery Code
$(“#lnkAll”).click(function(e) {
var currentVal = $(“#lnkAll”).text();
if (currentVal == “Check all”) {
$(‘input[type=checkbox]‘).attr(‘checked’, true);
$(“#lnkAll”).text(“Uncheck all”);
}
else if (currentVal == “Uncheck all”) {
$(‘input[type=checkbox]‘).attr(‘checked’, false);
$(“#lnkAll”).text(“Check all”);
}
});