Reputation: 513
I have a ListView, inside the ListView I placed html checkboxes(datarow and header), if I click header checkbox, it has to check all datarow checkboxes
Upvotes: 0
Views: 929
Reputation: 28134
Here is a jQuery sample:
$("#HeaderCheckbox").click(function() {
// get the state of the header checkbox (checked or unchecked)
var state = this.checked;
// apply it to the other checkboxes
$("input:checkbox").each(function() {
this.checked = state;
});
});
With plain JavaScript the technique is the same: get the state of the header checkbox and apply it to the others.
Upvotes: 3