Home  >  Article  >  Web Front-end  >  How to use js to achieve all selection and none selection_javascript skills

How to use js to achieve all selection and none selection_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:06:04864browse

js:

复制代码 代码如下:

function checkAll(name) {
var el = document.getElementsByTagName('input');
var len = el.length;
for(var i=0; iif((el[i].type=="checkbox") && (el[i].name==name)){
el[i].checked = true;
}
}
}
function clearAll(name) {
var el = document.getElementsByTagName('input');
var len = el.length;
for(var i=0; iif((el[i].type=="checkbox") && (el[i].name==name)){
el[i].checked = false;
}
}

}

html:
复制代码 代码如下:

全选
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