Check uncheck all checkbox in web form st using jquery

Check uncheck all check boxes on an 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 page 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”);



Comments are closed.