I have a shopping cart button integrated using snipcart. I've created a select menu with product options and I have some javascript that ties the selected option to the button so that the correct option is added to the cart when clicking "add to cart".
I would like to use buttons instead of a dropdown select menu. I'm not sure how to change my code.
<select id="color">
<option>red</option>
<option>blue</option>
<option>yellow</option>
</select>
<button
id="add-button"
class="snipcart-add-item
data-item-name="shirt"
data-item-custom1-name="color"
data-item-custom1-options="red|blue|yellow">
Add to cart
</button>
<script>
$('#color').change(function() {
$('#add-button').attr('data-item-custom1-value', $(this).val());
});
</script>