How to enter javascript function in Button link box

We would like to call a Javascript function using the Image with Text Overlay section’s Button link. The text box for the link entry does not appear to allow such a javascript call to be entered. See image below. Any suggestions you have would be much appreciated.

John

@jfkScollar

You can’t. You’ll need to create an event listener on that button and, whenever it’s clicked, you can call the function you wish.

Kind regards,
Diego

Hi @diego_ezfy ,

Thank you for your response.

As the Button’s class is generic and there are multiple Buttons that have the same class, how is one to assign an unique ID to the button to create an event listener on that button?

Thanks,

John

Hi @lucas05021 ,

I haven’t. Thanks for asking. Hoping someone has and can post it here.

I’m disappointed that Shopify does not support javascript function calls to be entered for Links (hrefs) in their editor. Javascript function calls in hrefs are such a normal (and powerful) approach to custom functionality.

John