如何使用javascript选中/取消选中ListView中的所有HTML复选框
我有一个ListView,在ListView中我放置了html复选框(datarow和header),如果我单击header复选框,它必须选中所有datarow复选框如何使用javascript选中/取消选中ListView中的所有HTML复选框,javascript,asp.net,.net,Javascript,Asp.net,.net,我有一个ListView,在ListView中我放置了html复选框(datarow和header),如果我单击header复选框,它必须选中所有datarow复选框 $("#HeaderCheckbox").click(function() { // get the state of the header checkbox (checked or unchecked) var state = this.checked; // apply it to the other checkboxe
$("#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;
});
});
对于纯JavaScript,技术是相同的:获取标题复选框的状态并将其应用于其他复选框。以下是jQuery示例:
$("#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;
});
});
对于纯JavaScript,技术是相同的:获取标题复选框的状态并将其应用于其他复选框