If I click into a div area and the checkbox is checked, if checked show clicked alert else unchecked is show unchecked alert. But else is not working.
$("#hellofortest").on('click', function() {
var checkbox = $(this).find('input[type=checkbox]');
if (checkbox.prop("checked", !checkbox.prop("checked"))) {
alert("Check box in Checked");
} else {
alert("Check box is Unchecked");
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="hellofortest">
<div class="reg-header">
<div class="reg-header-title">Title</div>
</div>
<div class="ceo-previous-data-checkbox">
<div class="bx-item-field">
<input type="checkbox" id="previous_info" name="previous_info" value="previous">
</div>
</div>
</div>