how to call javascript function in html button code example
Example 1: javascript onclick
document.getElementById("myBtn").addEventListener("click", function() {
alert("Hello World!");
});
Example 2: how to call a function with a button in javascript
<script>
function myFunction()
{
document.write("<h1>HELLO</h1>")
}
</script>
<button onclick="myFunction()">Click</button>