How to call external JavaScript function from an HTML button onclick?

To call external JavaScript function from an HTML button onclick, add this attribute: onclick="myFunction()".

So if this is your button:

<button>I am a button!</button>

Then you can call an external global function myFunction (when the button is clicked) by adding this onclick attribute:

<button onclick="myFunction()">I am a button!</button>