var button = document.querySelector('button'); button.onclick = function() { //do stuff }
document.getElementById('button').onclick = function() { alert("button was clicked"); };