call function from button js code example
Example 1: how to call a function with a button in javascript
<script>
function myFunction()
{
document.write("<h1>HELLO</h1>")
}
</script>
<button onclick="myFunction()">Click</button>
Example 2: button functions html
<script>
function myFunction() {
alert("ALERT");
}
</script>
<button onclick="myFunction">Click</button>