Run javascript function using button component

May it’s very simple but I do not understand how to call a function using the button component.
I created a custom component and pasted this simple code:

script>

  function myFunction() {

    alert('Button clicked!');

  }

</script>

And I did find how to run the script with text links or button links…
Please help me,
Thank you in advance

Thanks for sharing, Francis. For dummies (e.g. me), was the addition of the # in the URL box the thing that made that work?

And where did you put the code for the actual function being called?

Yes, the addition of the # in the URL box do the trick

About the function :

Thanks for that. I’ve been using the HTML snippets for creating things like image maps, but I was wondering if the function you were calling from the button was something you had added to the site template code as a global function. Your post makes me think that something I have been trying to get work (and failing) with a pointer events attribute for SVG’s could be applied as an HTML snippet

1 Like