I want to be able to check and uncheck a checkbox by clicking its parent DIV.
html:
<div class="insurance-option-select">
<input name="insurance[Auto]" type="checkbox" value="1">
</div>
<div class="insurance-option-select">
<input name="insurance[Home]" type="checkbox" value="2">
</div>
js:
$('.insurance-option-select').on('click', function () {
if ($(this).find('input').prop('checked')) {
$(this).find('input').removeAttr('checked');
} else {
$(this).find('input').attr('checked', true);
}
});
css:
.insurance-option-select {
background: red;
padding: 30px;
margin: 30px auto;
}
.insurance-option-select:hover {
background: green;
}
Problem is it only works once. http://jsfiddle.net/zbh691y0/