<html>
<head>
<title>test page</title>
<meta http-equiv="content-type" content="text/htmlcharset=utf-8">
</head>
<body>
<input type="checkbox" name="sports[]" value="0">足球<br>
<input type="checkbox" name="sports[]" value="10">篮球<br>
<input type="checkbox" name="sports[]" value="20">排球<br>
<input type="checkbox" name="sports[]" value="30">乒乓球<br>
<input type="checkbox" name="sports[]" value="40">羽毛球<br>
<input type="checkbox" name="sports[]" value="50">橄榄球<br>
<input type="checkbox" name="sports[]" value="60">冰球<br>
<input type="checkbox" name="sports[]" value="70">曲棍球<br>
<input type="checkbox" name="sports[]" value="80">同求<br><br>
<input type="checkbox" id="chkAll" onclick="chkAll(this)">全选
<script type="text/javascript">
var objs = document.getElementsByName('sports[]')
function chkAll(obj){
for (var i = objs.length - 1 i >= 0 i--) {
objs[i].checked = obj.checked
}
}
</script>
</body>
</html>
帮你写好了var allElements = document.getElementsByTagName("input")
var classElements=[]
for (var i = 0 i < allElements.length i++) {
if (allElements[i].getAttribute("stor_id") == "a1") {
classElements[classElements.length] = allElements[i]
}
}
alert(classElements)