<title>haran.info_jquery实例_全选全不选反选_select-all_unselect-all_reverse</title> <meta http-equiv="content-type"content="text/html; charset=UTF-8"/> <script src="/js/jquery-1.8.3.min.js"type="text/javascript"></script><!-- 引入Jquery -->
<styletype="text/css">
<!--
#div1{
width:980px;
margin:0 auto;
position:relative;
text-align:left;
padding-left:400px;
line-height:30px;
border:1px dotted #0075c5;
}
li{
display:block;
list-style:none;
float:left;
position:relative;
padding-left:20px;
}
.clr{
height:20px;
}
-->
</style>
<divid="div1">
<divclass="clr"> </div>
<!--选项开始-->
<inputtype="checkbox"/><ahref="haran.info">haran.info_脚本编程</a><br/>
<inputtype="checkbox"/><ahref="haran.info">haran.info_网站编程</a><br/>
<inputtype="checkbox"/><ahref="haran.info">haran.info_系统管理</a><br/>
<inputtype="checkbox"/><ahref="haran.info">haran.info_服务器配置</a><br/>
<inputtype="checkbox"/><ahref="haran.info">haran.info_系统运维</a><br/>
<inputtype="checkbox"/><ahref="haran.info">haran.info_博客</a><br/>
<inputtype="checkbox"/><ahref="haran.info">haran.info_首页</a><br/>
<!--选项结束-->
<!--功能按钮开始-->
<inputtype="button"id="selAll"value="全选"/>
<inputtype="button"id="unselAll"value="全不选"/>
<inputtype="button"id="reverse"value="反选 "/>
<!--功能按钮结束-->
<divclass="clr"> </div>
</div><!--关闭div1-->
<scripttype="text/javascript">
$(document).ready(function () {
$("#selAll").click(function () { //":checked"匹配所有的复选
$("#div1 :checkbox").attr("checked", true); //"#div1 :checked"之间必须有空格checked是设置选中状态。如果为true则是选中fo否则false为不选中
});
$("#unselAll").click(function () {
$("#div1 :checkbox").attr("checked", false);
});
//理解用迭代原理each(function(){})
$("#reverse").click(function () {
$("#div1 :checkbox").each(function () {
$(this).attr("checked",!$(this).attr("checked")); //!$(this).attr("checked")判断复选框的状态:如果选中则取反
});
});
});
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有