checkbox 全选 /全不选

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
*{
margin:0;
padding:0;
}
ul{
list-style-type:none;
}
#wrap{
width:150px;
margin:50px auto;
}
</style>
<title></title>
</head>
<body>
<div id="wrap">
<input type="button" id="selecte_all" value="全选"/>
<input type="button" id="selecte_no" value="全不选"/>
<input type="button" id="selecte_etr" value="反选"/>
<ul>
<li><input type="checkbox" class="about" />资料</li>
<li><input type="checkbox" class="about" />简历</li>
<li><input type="checkbox" class="about" />经历</li>
<li><input type="checkbox" class="about" />爱好</li>
<li><input type="checkbox" class="about" />其他</li>
</ul>
</div>
<script type="text/javascript">
window.οnlοad=init;
function init(){
var selecte_all=document.getElementById('selecte_all');
var selecte_no=document.getElementById('selecte_no');
var selecte_etr=document.getElementById('selecte_etr');
var check_list=document.getElementsByClassName('about');

selecte_all.οnclick=function(){
for(i=0;i<check_list.length;i++){
check_list[i].checked=true;
};
}

selecte_no.οnclick=function(){
for(i=0;i<check_list.length;i++){
check_list[i].checked=false;
};
}

selecte_etr.οnclick=function(){
for(i=0;i<check_list.length;i++){
check_list[i].checked=!check_list[i].checked;
};
}
}

</script>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值