Jquery 根据选中的另一个复选框设置一个复选框

Jquery Set a checkBox based on another checkbox selected

我有两个复选框,一旦我勾选了第一个,第二个复选框应该简单易行地被选中!但我看不出有什么问题以及为什么 html 编辑器中没有选中第二个复选框 还有一件事,我的复选框的导出值为 1,因此选中时应为 1

var opt_identity = $('#chkOpt_contractType').val();
var ShortSale = $('#chkOptShortSale').val();

if (opt_identity == 1) 
{   
    // I tried both of these lines but still i dont see the check box being check 
$('input[name="chkOptShortSale"][value='1']').prop('checked', true);
$('#chkOptShortSale').prop('checked', true);
} else {
$('.checked').removeAttr('checked');
alert('HH Else = ' + ShortSale); 

使用这个

if (opt_identity == 1) {   
$('input[name="chkOptShortSale"][value="1"]')).prop(''checked'', true);
$('#chkOptShortSale').prop('checked', true);
} else {
$('.checked').removeAttr('checked');
alert('HH Else = ' + ShortSale); 
}