您的位置:首页 > Web前端 > JQuery

jQuery操作CheckBox的方法(选中,取消,取值)

2014-04-27 21:08 716 查看
代码:

<tr>

<td>用户权限:</td>

<td>

<select id="userRight" id="groupRight" name="groupRight" style="width:200px;" onchange="selecgRight(this);">

<option value="1">系统管理员</option>

<option value="2">普通用户</option>

<option value="3">自定义权限</option>

</select>

</td>

</tr>

<tr>

<td></td>

<td>

<input type="checkbox" value="1" checked name="userGroupRight">查询本人导入的检查记录</input><br>

<input type="checkbox" value="2" checked name="userGroupRight">查询所有检查记录</input><br>

<input type="checkbox" value="3" checked name="userGroupRight">查询本人的操作日志</input><br>

<input type="checkbox" value="4" checked name="userGroupRight">查询所有操作日志</input><br>

<input type="checkbox" value="5" checked name="userGroupRight">修改用户密码</input><br>

<input type="checkbox" value="6" checked name="userGroupRight">管理用户</input>

</td>

</tr>

function selecgRight(obj){

var curValue=obj.value;

if(curValue==1){

//选中所有的复选框

$("[name='userGroupRight']").attr("checked",'true');

}else if(curValue==2){

$("[name='userGroupRight']").removeAttr("checked");

$("[name='userGroupRight']").each(function(){

if($(this).val()==1){

$(this).attr("checked",'true');

}

if($(this).val()==3){

$(this).attr("checked",'true');

}

if($(this).val()==5){

$(this).attr("checked",'true');

}

})

}else{

//取消所有复选框

$("[name='userGroupRight']").removeAttr("checked");

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: