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

js 设置多个复选框选中和取消选中

时间:2017-07-17 14:31:55      阅读:331      评论:0      收藏:0      [点我收藏+]

标签:选中   checked   info   error   function   length   取消   ons   警告   

// 设置选中 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 设置多个复选框选中和取消选中

标签:选中   checked   info   error   function   length   取消   ons   警告   

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

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