Answers for "how to assign a js function to a button in html"

3

how to call a function with a button in javascript

<script>
		function myFunction()
		{
			document.write("<h1>HELLO</h1>")
		}
	</script>
<button onclick="myFunction()">Click</button>
Posted by: Guest on November-12-2020
0

how to add function to button in html

<script>
 function myFunction() {
   alert("ALERT");
 }
</script>
<button onclick="myFunction()">Click</button>
Posted by: Guest on February-14-2022

Code answers related to "how to assign a js function to a button in html"

Browse Popular Code Answers by Language