Two different methods are used to implement the full selection and inverse selection of the checkbox using js:
Method 1:
1: js implements the full selection function of the checkbox:
function checkAll()
{
var code_Values = document.getElementsByTagName(" input");
for(i = 0;i < code_Values.length;i ){
if(code_Values[i].type == "checkbox")
{
code_Values[i ].checked = true;
}
}
}
2: js implements the checkbox anti-selection function:
function uncheckAll()
{
var code_Values = document.getElementsByTagName("input");
for(i = 0;i < code_Values.length;i ){
if(code_Values[i].type == "checkbox")
{
code_Values[i].checked = false;
}
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn