I'm wondering if there is a way in jQuery to check/uncheck a checkbox when someone clicks an entire div layer. Like having a massive selection area, essentially.
Any ideas?
Here is an example... I am trying to make the around the checkbox clickable to toggle the individual checkbox, pretty much.
<fieldset>
<div>
<input type="checkbox" id="Checkbox1" />
</div>
Person 1<br />
</fieldset>
<fieldset>
<div >
<input type="checkbox" id="Checkbox2" />
</div>
Person 2<br />
</fieldset>
Perhaps use the clicked div as the parent.
$(function() {
$('#divId').toggle(
function(event) {
$(this).find('input').attr('checked', true);
},
function(event) {
$(this).find('input').attr('checked', false);
}
);
});
This should only check the boxes inside the #divId that's clicked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With