mvc4
C# MVC4 How to implement select all checkbox.
Reply to discussion (solution)
1 | $( "#chkAll" ).click( function () { if (this.checked) { $( "input[name='chkId']" ).each( function () { this.checked = true; }); } else { $( "input[name='chkId']" ).each( function () { this.checked = false; }); } });
|
Copy after login
1 | <input type= "checkbox" id= "chkAll" />全选 <input type= "checkbox" name= "chkId" value= "id1" /> <input type= "checkbox" name= "chkId" value= "id2" />
|
Copy after login
1 | window.onload = function () { $( "#chkAll" ).click( function () { $( "input[name='chkId']" ).attr( "checked" , this.checked); }); }
|
Copy after login