How to get selected variant option name using javascript

WizardofDeath
Tourist
9 0 0

Hi All,

Is there any way that we can get the correct variant title selected on the product-form page when the user clicks on Add to cart button?

for example: product variant are color:

dropdown options will be - red

                                              black

                                              yellow

                                              green

 

If user select on yellow and clicks on Add to cart button.

{{variant.title}} should return yellow as output using javascript.

 

Reply 1 (1)
attotasolutions
Shopify Partner
26 0 15

Hi,

Please let me know if anyone has idea on it.