我有一个具有不同权限的用户的下拉列表。用户的不同权限是查看、编辑或删除。从下拉列表中选择用户时,复选框应根据他们拥有的权限进行更新。我试过使用 .prop() 和 .attr() 无济于事。http://jsfiddle.net/DWM4r/
HTML
<select class='select210'>
<option class='user1'>wjazi@deloitte.com</option>
<option class='user2'>aschwem@company.com</option>
<option class='user3'>tcooksnow@usa.com</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);
});