<!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>
單擊a的時候會全部選中但是一閃就沒了,請問是什么原因
qq_我的酒窩沒有酒_0
2017-11-07 17:39:56