Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用javascript选中/取消选中ListView中的所有HTML复选框_Javascript_Asp.net_.net - Fatal编程技术网

如何使用javascript选中/取消选中ListView中的所有HTML复选框

如何使用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

我有一个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 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,技术是相同的:获取标题复选框的状态并将其应用于其他复选框