This jQuery function is always returning true in alert(isChecked), even when unchecked:
pls note .accrualCheckbox is the class name of Div , not the class that is set for check box. I removed the code if ($(this).prop('checked', 'checked')), now it is always returning as 'false'
$('.accrualCheckbox').click(function () {
var isChecked = $(this).attr('checked') ? true : false;
alert($(this).attr('checked'));
alert(isChecked);
if ($(this).prop('checked', 'checked')) {
var parentDiv = $(this).parents('.searchLine');
$(parentDiv).css('border', '1px solid red');
//Checkbox
$(parentDiv).find("input[type=text]").each(function () {
$(this).val('B');
$(this).prop('disabled', true);
});
}
});
});
I kept the check box in the div:
<div class="accrualCheckbox">
@Html.CheckBox("chkSalesAndMarketing")
</div>
});at the end of the first code block. @user2543573, why is that there?