Can someone show me what I am doing wrong here?
I am trying to execute a function when a button is clicked.
The HTML:
<button id="btn1">Press me!</button>
<input type="button" id="btn2" value="Press me!"/>
The javascript:
var btn1 = document.getElementById('btn1'),
btn2 = document.getElementById('btn2');
function do() {
alert('Yay!');
}
btn1.onclick = do;
btn2.onclick = do;
Here's a demo. I'm not sure why it's not working. It's probobly something way to obvious for me to notice. :)