how to make a button call a javascript function code example
Example 1: onclick a tag
<a href='http://www.google.com' onclick='return check()'>check</a>
<script type='text/javascript'>
function check() {
return false;
}
</script>
Example 2: javascript click event
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
Example 3: javascript onclick button
var button = document.querySelector('button');
button.onclick = function() {
//do stuff
}
Example 4: calling function on click html
<img src="hospital.png" id="hospitals" onclick="damarkers();">