1var element = document.getElementById("elem");
2element.onclick = function(event) {
3 console.log(event);
4}
1<script>
2function myFunction() {
3 alert("ALERT THIS FUNCTION HAS RUNNED");
4}
5</script>
6<button onclick="myFunction">click to run function</button>
1<script>
2 function myFunction() {
3 alert("ALERT");
4 }
5</script>
6<button onclick="myFunction">Click</button>
1 document.getElementById("Save").onclick = function ()
2 {
3 alert("hello");
4 //validation code to see State field is mandatory.
5 }