返回input全选...登陆

input全选

董锋2019-05-21 11:30:35227

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>全选</title>

<style type="text/css">

.box{width: 100px;height: 200px;border: 1px solid #ccc;border-radius: 6px; margin:20px auto;}

.box div{border: 1px solid #aaa;border-radius: 6px; margin:20px auto;}

.box  input{border: 1px solid #fff;border-radius: 6px; margin:20px auto;}

</style>

<script type="text/javascript">

function checkall(){


var checkall,item;

checkall=document.getElementById("check_all");

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

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

if(checkall.checked){

item[i].checked=true;

}else{

item[i].checked=false;

}

}



}

</script>

<body>

<div class="box"></div>

<div>

<input type="checkbox" id="check_all" onclick="checkall()"><label for="check_all">全选</label>

<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>

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

</div>

</body>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送