饮歌长啸 2019-03-03 08:04:35<!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>
4 回答
- 4 回答
- 0 关注
- 417 浏览
添加回答
举报
0/150
提交
取消