jquery根据后台返回值设置checkbox选中
来源:互联网 发布:守望先锋 mac 编辑:程序博客网 时间:2024/06/04 18:43
根据后台返回的值选中checkbox,使用jquery代码很简单,这里记一下以后方便查阅
返回user的json对象如下
user:{id:10name:testroles:[{id:1,name:管理员},{id:2,name:普通用户}]}
页面html
<div class="col-sm-10"> <label class="checkbox-inline"> <input type="checkbox" name="role" value="1"> 管理员 </label> <label class="checkbox-inline"> <input type="checkbox" name="role" value="2"> 普通用户 </label> <label class="checkbox-inline"> <input type="checkbox" name="role" value="3"> 人力 </label> <label class="checkbox-inline"> <input type="checkbox" name="role" value="4"> 记者 </label></div>
jquery
var roles = returnData.roles; if(roles != null) { $.each(roles, function(key, value) { $("input[name='role'][value='"+value.roleId+"']").attr("checked", true); }); }
阅读全文
0 0
- jquery根据后台返回值设置checkbox选中
- Jquery根据后台数居设置select。radio,checkbox选中
- jquery根据值选中相应的checkbox
- easyui tree 根据后台返回的数据属性的值控制checkbox的选中状态(可不可用)
- Jquery操作select,radio,checkBox,获取选中项的值和文本,根据值和文本设置选中项
- Jquery操作select,radio,checkBox,获取选中项的值和文本,根据值和文本设置选中项
- jquery 根据值设置radio选中
- jquery无法设置checkbox选中
- 根据被选中的 radio 值,设置 checkbox 是否可用
- jquery设置radio选中:根据单选名及值选中
- jquery checkbox选中值
- jquery获取select、checkbox文本值,设置select选中 radio
- jQuery设置 select、radio、checkbox 默认选中的值
- jQuery设置和获取select、checkbox、radio的选中值
- select根据后台值选中
- jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关设置
- jQuery如何设置checkbox选中状态
- JQuery 获取选中checkbox值
- 转换汇编到shellcode的过程
- 快速简单解决Ubuntu安装后无wifi列表, 连不了网.
- RecyclerView自定义分割线实现
- 浅述经典的4种卷积网络之(3)Google Inception Net
- 通过dao操作数据库的大概过程
- jquery根据后台返回值设置checkbox选中
- 乱搞——均分纸牌
- Android酷炫实用的开源框架(UI框架)
- The value of attribute "title" associated with an element type "question" must not contain the '<' c
- 里氏替换原则
- python的模块
- 【Unity】KEngineExtensions
- qt布局整理合集---- 1.1布局管理器
- 机器学习-回归算法