How do I add javascript or jquery script to a button or text in Webflow

I see in your read-only link you’re using Link With Arrow as class name. Weflow will convert it to link-with-arrow so it might have conflicted with the way you defined your buttons array. Right now your buttons array reads: buttons = document.getElementsByClassName("modal");, I think you could try buttons = document.getElementsByClassName("link-with-arrow"); and see how it goes.

EDIT: would you have a published link to provide for us to have a look at the issue ?

EDIT 2:

but am having an issue now where all classes with that name (link-with-arrow) are launching a modal

That is precisely what the script should be doing, every button with that class should launch a modoal on click. They shouldn’t launch the modal all in the same time, ony on button click, like on the codepen.

Nice website by the way ! :slight_smile:

Thanks @anthonysalamin, really appreciate you staying with this (especially on a Saturday)!

I don’t know if this is the most elegant solution, but I just added a class name of ‘modal’ to the buttons that I want to launch the modal, so I could specifically target them in the javascript. Seemed like an easy enough workaround, so I went with it :wink: Anyway, it’s working now so that’s all that matters.

Grateful for you, brother :pray:t3:

1 Like

@anthonysalamin, thank you for all you’ve done so far. I’m running into some issues with what seemed like a simple onclick function, but I want to try and work it out myself if I can. Any chance you would republish your original code pen for reference?

Cheers!