var myElem = document.getElementByID('ElemID'); myElem.onclick = function() { //do stuff }
<button onclick="myFunction()">Click me</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = "Hello World"; } </script>
<button onclick="Function()">Text</button>