为了账号安全,请及时绑定邮箱和手机立即绑定

单击a的时候会全部选中但是一闪就没了,请问是什么原因

单击a的时候会全部选中但是一闪就没了,请问是什么原因

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>商品全选</title> <style> .btn{ width: 50px; background-color: #ccc; text-align: center; line-height: 30px; display: block; text-decoration: none; font-size: 14px; color: black; } input{ display: block; } </style> <script> window.onload = function(){ var btn = document.getElementById('btn'); var input = document.getElementsByTagName('input'); var i = 0; btn.onclick = function(){ for(i=0;i<input.length;i++){ input[i].checked = true; } } } </script> </head> <body> <a href="" id="btn">全选</a> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> </body> </html>
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 2233 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信