how to give a function to a button when clicked in javascript code example
Example 1: javascript button onclick programmatically
document.getElementById("myCheck").click();
Example 2: button on click script
<button onclick="myFunction()">Click me</button>