码迷,mamicode.com
首页 > Web开发 > 详细

JS 设置复选框的选中与取消选中

时间:2017-07-17 15:20:22      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:each   post   action   parse   警告   click   val   als   info   

// 设置选中 function setCheckboxClick(obj) { if(obj == null) { $.messager.alert(‘警告‘, "请选择要设置选中的项!",‘warning‘); } // alert(obj.value); var authorityId = obj.value; $.ajax({ type: ‘post‘, url: ‘getAuthorityByAuthorityId.action‘, data: {"authorityId" : authorityId}, dataType: ‘json‘, success:function(data) { console.info(data); var d = $.parseJSON(data); //$(":checkbox[name=authorityId]").prop("checked",false); // obj.checked = true; $(":checkbox[name=authorityId]").each(function(){ var currentAuthorityId = $(this).val(); for(var i = 0; i < d.length; i++) { if(currentAuthorityId == d[i].authorityId) { // $(this).prop("checked",true); if ($(this).prop("checked") == true) { $(this).prop("checked", false); } else { $(this).prop("checked",true); } } } }); }, error:function() { } });

JS 设置复选框的选中与取消选中

标签:each   post   action   parse   警告   click   val   als   info   

原文地址:http://www.cnblogs.com/rgcdlb/p/7194095.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!