Answer the question
In order to leave comments, you need to log in
How to mark checkbox on select select?
Tell me, there is such a select
<select class="item-list" name="item-list">
<option value="item-1">Item name 1</option>
<option value="item-2">Item name 2</option>
<option value="item-3">Item name 3</option>
<option value="item-4">Item name 4</option>
</select>
<div class="additionals">
<span class="checkbox-input">
<input name="add[0]" type="checkbox" value="Delivery" data-price="40" id="add-0">
<label for="add-0">Delivery - $40</label>
</span>
<span class="checkbox-input">
<input name="add[1]" type="checkbox" value="Child Seat" data-price="20" id="add-1">
<label for="add-1">Child Seat - $20</label>
</span>
<span class="checkbox-input">
<input name="add[2]" type="checkbox" value="GPS" data-price="20" id="add-2">
<label for="add-2">GPS - $20</label>
</span>
</div>
<option value="item-2">Item name 2</option>
, then a checkmark with<input name="add[0]" type="checkbox" value="Delivery" data-price="40" id="add-0">
should be removed, and in other cases stood.
Answer the question
In order to leave comments, you need to log in
$('select').on('change', function(){
$('#add-0').prop('checked', this.value === 'item-2')
})
https://jsfiddle.net/2hkj1dnL/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question