JavaScrip-—全选

Original 2019-03-22 10:55:06 147
abstract:<!doctype html><html><head><meta charset="utf-8"><title>JavaScrip-—全选</title><style type="text/css">.box{ width:80px; height:150px; border

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>JavaScrip-—全选</title>

<style type="text/css">

.box{ width:80px; height:150px; border: 1px solid #666; border-radius:5px; padding:5px 10px; margin:0px auto; box-shadow:2px 2px 5px #CCC;}

.box div{ border-bottom:1px solid #666; padding-bottom:5px;}

.box input{ margin:5px;}

</style>


<script type="text/javascript">

 function aa(){

var aa,item;

 aa=document.getElementById('aa')

 item=document.getElementsByName("item[]")

 for(var i=0;i<item.length;i++){

if(aa.checked){

item[i].checked=true

}else{

      item[i].checked=false}

}

 

 

 }

</script>


</head><body>






<div class="box">

<div> <input type="checkbox" id="aa" onClick="aa()"> <label for="aa">全选</label> </div>

 <input type="checkbox" name="item[]">选项1<br>

 <input type="checkbox" name="item[]">选项2<br>

 <input type="checkbox" name="item[]">选项3<br>

 <input type="checkbox" name="item[]">选项4<br>

 <input type="checkbox" name="item[]">选项5<br>



</div>





</body>

</html>

















Correcting teacher:灭绝师太Correction time:2019-03-22 11:31:09
Teacher's summary:完成 的不错!全选案例后期使用场景较多,要好好掌握!

Release Notes

Popular Entries