I have the following selector with options:
<select name="" id="product-selector" class="list_item">
<option value="74552" data-id="74552" data-content="50 Items <span class='price' data-count='50 Items' data-price='$20'>$20"> </option>
<option value="74553" data-id="74553" data-content="100 Items <span class='price' data-count='100 Items' data-price='$30'>$30"> </option>
<option value="74554" data-id="74554" data-content="300 Items <span class='price' data-count='300 Items' data-price='$45'>$45"> </option>
<option value="74555" data-id="74555" data-content="500 Items <span class='price' data-count='500 Items' data-price='$60'>$60"> </option>
<option value="74556" data-id="74556" data-content="1000 Items <span class='price' data-count='1000 Items' data-price='$100'>$100"> </option>
</select>
And I have the following button:
<a role="button" aria-label="Add to Wishlist" class="tinvwl_add_to_wishlist_button" data-tinv-wl-product="2050" data-tinv-wl-productvariation="74552" data-tinv-wl-productvariations="[74552]" data-tinv-wl-producttype="variation" data-tinv-wl-action="addto"><span class="tinvwl_add_to_wishlist-text">Add to Wishlist</span></a>
How can I ensure that when an option is selected, the data-tinv-wl-productvariation attribute in the button changes its value depending on the data-id= attribute of the selected option?
As an example, if I selected the option:
<option value="74553" data-id="74553" data-content="100 Items <span class='price' data-count='100 Items' data-price='$30'>$30"> </option>
with data-id="74553"
my button takes its value and transforms into the following:
<a role="button" aria-label="Add to Wishlist" class="tinvwl_add_to_wishlist_button" data-tinv-wl-product="2050" data-tinv-wl-productvariation="74553" data-tinv-wl-productvariations="[74553]" data-tinv-wl-producttype="variation" data-tinv-wl-action="addto"><span class="tinvwl_add_to_wishlist-text">Add to Wishlist</span></a>
I tried to try various options, but temporarily due to lack of knowledge and experience, I cannot write the correct script.