<table id="dtsResult" class="table table-striped table-bordered" cellspacing="0" width="100%"> <thead> <tr> <th>SelectAll<input type="checkbox" id="CheckAllRes" /></th> <th>Unit</th> </tr> </thead> <tbody> @foreach (var item in ViewBag.Result) { <tr> <td><input type="checkbox" id=@item.RecordID name="res" class="chkres" /></td> <td> @item.UnitNo</td> </tr> } </tbody> </table> Here is my Jquery Function $(document).ready(function () { $('#CheckAllRes').on("click", function (){ var chk = $(this).is(':checked'); $(".chkres", "#dtsResult").each(function () { if (chk) { $(this).attr("checked", true); } else { $(this).attr("checked", false); } }); }); });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)