I have a list of checkboxes like so below wrapped in a div.
<div>
<input type="checkbox" value="1" class="checkbox"/><br>
<input type="checkbox" value="2" class="checkbox"/><br>
<input type="checkbox" value="3" class="checkbox"/>
</div>
<select class="value">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
Using jquery, i would like on change for the select option, the checkbox with the value 1 to be checked.
Try:
$(".value").change(function() {
$('input[type=checkbox][value=1]').prop('checked', true);
});
// Call the select list on change event
$(".value").change(function() {
// Reset all the check-boxes ckecked
$('input:checkbox').prop('checked', false);
// Set the chekbox with the same value as select option
$('input:checkbox[value="' + $(this).val() + '"]').prop('checked', true);
});
DEMO HERE
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