<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<form>
请选择你爱好:<br>
<input type="checkbox" name="hobby" id="hobby1"> 音乐
<input type="checkbox" name="hobby" id="hobby2"> 登山
<input type="checkbox" name="hobby" id="hobby3"> 游泳
<input type="checkbox" name="hobby" id="hobby4"> 阅读
<input type="checkbox" name="hobby" id="hobby5"> 打球
<input type="checkbox" name="hobby" id="hobby6"> 跑步 <br>
<input type="button" value = "全选" onclick = "checkall();">
</form>
<script type="text/javascript">
function checkall(){
var hobby = document.getElementsByTagName("input");
hobby.forEach(function(v){v.checked=true;}); //为什么chrome这句报函数forEach不存在?
[1,2,3].forEach(function(v){alert(v);});//而这句就不报错呢?
}
</script>
</body>
</html>
小熊上大二啦
安九思米大
码男
杨少峰
fdsgasgg
精慕门9417850
Developer_Zuck
属于码农的生活
慕婉清8071797
幕布斯3108837
相关分类