返回 全选则框的案列... 登陆

全选则框的案列

Risco 2018-12-10 22:29:40 215

总结   先声明  两个框   在获取两个框  在用for循环辨别真假

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

.xuanze{width: 150px;height: 280px;border: 1px solid;border-radius: 5px;margin: 20px auto;padding: 5px 10px;}

.xuanze div{border-bottom: 1px solid #000;padding-bottom: 8px;margin-bottom: 8px;}

.xuanze input{margin:8px;}

</style>

<script type="text/javascript">

function quanxuanr(){

var quanxuan,gouxuan;

quanxuan=document.getElementById('quanxuan')

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

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

if (quanxuan.checked) {

gouxuan[i].checked=true;

}else{

gouxuan[i].checked=false;

}

}

}

</script>

</head>

<body>

<div>

<div>

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

</div>

    <input type="checkbox" name="gouxuan[]">1<br>

    <input type="checkbox" name="gouxuan[]">2<br>

    <input type="checkbox" name="gouxuan[]">3<br>

    <input type="checkbox" name="gouxuan[]">4<br>

    <input type="checkbox" name="gouxuan[]">5<br>

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

    <input type="checkbox" name="gouxuan[]">7<br>

    <input type="checkbox" name="gouxuan[]">8<br>

</div>


</body>

</html>


最新手记推荐

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

全部回复(0)我要回复

暂无评论~
  • 取消 回复 发送
  • PHP中文网