<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Html study</title>
<script type="text/javascript">
function forSelect(){
var mydiv = document.getElementsByName('select');
var myselect = document.getElementById('select_all');
for(var i=0; i<mydiv.length; i++){
if(myselect.checked == false){
mydiv.item(i).checked = false;
}else{
mydiv.item(i).checked = true;
}
}
}
</script>
</head>
<body>
<input type="checkbox" onChange="forSelect()" id="select_all">select All</input><br></br>
<div id="mydiv">
<input type="checkbox" name='select'>select one</input><br/>
<input type="checkbox" name='select'>select two</input><br/>
<input type="checkbox" name='select'>select three</input><br/>
<input type="checkbox" name='select'>select four</input><br/>
</div>
</body>
</html>
javaScript 案例之复选框的全选和取消
最新推荐文章于 2017-12-13 18:30:46 发布