我有一个具有不同权限的用户下拉菜单。用户的不同权限是查看,编辑或删除。从下拉菜单中选择用户时,复选框应根据其拥有的权限进行更新。我试过使用.prop()和.attr()无济于事。 http://jsfiddle.net/DWM4r/选择一个选项来检查/取消选中复选框不起作用?
HTML
<select class='select210'>
<option class='user1'>[email protected]</option>
<option class='user2'>[email protected]</option>
<option class='user3'>[email protected]</option>
</select>
<input type='checkbox' checked class='viewChk' />View
<input type='checkbox' checked class='editChk' />Edit
<input type='checkbox' checked class='delChk' />Delete
jQuery的
$('.user3').click(function() {
$('.viewChk').attr('checked', true);
$('.editChk').attr('checked', false);
$('.delChk').attr('checked', false);
});
$('.user2').click(function() {
$('.viewChk').prop('checked', true);
$('.editChk').prop('checked', true);
$('.delChk').prop('checked', false);
});
$('.user1').click(function() {
$('.viewChk').prop('checked', true);
$('.editChk').prop('checked', true);
$('.delChk').prop('checked', true);
});