<button id="myButton" onclick="alert(1);"> My Button </button>
window.document.getElementById("myButton").onclick = function(){ alert(2); }