ITPub博客

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

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

作者:jerrysun 时间:2019-04-11 15:38:37 0 删除 编辑
<!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>


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/151/viewspace-3166716/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: SQL注入如何防范?
请登录后发表评论 登录
全部评论

注册时间:2018-09-29

  • 博文量
    122
  • 访问量
    16192