1document.getElementById("myBtn").addEventListener("click", function() {
2 alert("Hello World!");
3});
1var element = document.getElementById("elem");
2element.onclick = function(event) {
3 console.log(event);
4}
1 document.getElementById("Save").onclick = function ()
2 {
3 alert("hello");
4 //validation code to see State field is mandatory.
5 }
1var myElem = document.getElementByID('ElemID');
2myElem.onclick = function() {
3 //do stuff
4}
1// The element id (TheElementID) and var name (myElement) can be named anything.
2var myElement = document.getElementByID('TheElementID');
3myElement.onclick = function() {
4 // Carry out a function here...
5}