Using HTML button element to change a variable in the Javascript

If your element is pre-defined in your HTML file, you can use select() to find it:

And then invoke method mousePressed() over the found element in order to add a callback to it:

2 Likes