CheckBox全选
来源:互联网 发布:android 源码 github 编辑:程序博客网 时间:2024/06/14 01:12
这里实现的效果是:
当点击选择的时候,显示一个div,上面有许多checkbox,
当点击全选的时候,会选中所有的checkbox。
遇到的问题:
在使用Jquery的attr做属性设置的时候,第一次全选和取消全选起作用,之后就不起作用,修复方法,使用prop函数。
具体如下:
<td class='tdEr' style="position:relative" id="InterType"> <div id="TypeSelect" style="cursor:pointer;width:100px;background:#CBC9C5;text-align:center;border-radius:5px;">选择</div> <div id="TypeDialog" style="width:200px;position:absolute;left:10px;top:30px;background:#DFDFDC;border-radius:10px; padding-left:10px;padding-top:10px;border:1px solid #C4C4C2;"> </div> </div> </td>
//选择接口类型
(“#TypeSelect”).click(function(){.ajax({
url: ‘${root}/statisticalAnalysis/002/listAllInterType.do’,
type : ‘post’,
data:{},
dataType : ‘text’,
success : function(data){
var dataStr=data.substr(1,data.length-2);
var arr=dataStr.split(“,”);
var str=''; str+='<input id="checkAll" type="checkbox" style="margin:0 5px 0 10px;"/>'; str+='<label for="checkAll">[@s.m 'allSelect'/]</label><br/>'; for(var i=0;i<arr.length;i++){ str+='<input id="abc'+i+'" type="checkbox" name="interType" value="'+arr[i].trim()+'" style="margin:0 5px 0 10px;"/>'; str+='<label for="abc'+i+'">'+arr[i].trim()+'</label>'; str+="<br/>"; } str+='<input type="button" value="[@s.m 'confirm2'/]" class="inputTwo inputQuery" id="confirmBut" style="position:absolute;bottom:5px;right:20px;"/>'; $("#TypeDialog").empty(); $("#TypeDialog").append(str); if(flag){ $("#TypeDialog").height($("#TypeDialog").height()+35); flag=false; } $("#TypeDialog").show(); $("#confirmBut").click(function(){ $("#TypeDialog").hide(); }); $("#checkAll").click(function(){ if($('#checkAll').is(':checked')) { $("#TypeDialog input[type='checkbox']").prop("checked",true);//注意这里 }else{ $("#TypeDialog input[type='checkbox']").prop("checked",false); } }); }, error : function(data){ alert("[@s.m 'notice103'/]"); } }); }); })
“`
当点击”选择”的时候,会发送ajax请求到后台加载checkbox的内容,这里代码有关于业务,标签是freemarker的,就不做过多解释,然后将后台获取到的数据做拼接后动态添加到DIV弹出框中。
阅读全文
0 0
- checkbox全选
- checkbox全选
- checkbox全选
- checkbox 全选
- CheckBox全选
- checkbox全选
- checkbox 全选
- checkbox全选
- checkbox 全选
- checkbox全选
- checkbox 全选
- 全选(CHECKBOX)
- checkbox全选
- checkBox全选
- CheckBox全选
- 全选checkbox
- CHECKBOX全选
- checkbox 全选
- android图片处理
- python数据持久存储:pickle模块的基本使用
- scala 的apply,update,unapply方法
- 53个要点提高PHP编程效率
- 虚拟机Centos开机以后,有eth0网卡,但是没有IP,Determine IP information for eth0.. no link present check cable
- CheckBox全选
- CentOS 7设置开机启动服务
- MongoDB分片搭建
- jsday04补充(dom基础)
- centos7 Berkeley DB在linux中的安装
- 【Python】Python3 List pop()方法
- 04:输出保留3位小数的浮点数
- 深入机器学习系列4-k-means
- Mongodb启动命令mongod参数说明