What am I doing wrong? If this is a duplicated question, please redirect me to the correct question because I can't find anything about it.
It is that simple:
I get this error: "Uncaught TypeError: Cannot set property 'onclick' of null"
In this hyper-mega-ultra-easy piece of code:
window.onload = function() {
document.write('<input id="a" type="button" value="This is a button :)">');
document.getElementById("a").onclick = alert("a");
}
How can this even be possible? Regards.