`getElementById` returning null [duplicate]
This question already has an answer here: Why does jQuery or a DOM method such as getElementById not find the element? 8 answers A case of document.getElementById returning null . I've read four other questions in SO, and read the reference on MDN, but I have no clue of what's wrong; please help me. Code is as follows: HTML <button id="btnButton1">Button1!</button><br> <button id="btnButton2">Button2!</button><br> <span id="spanOutPut"></span> Javascript getBYid = function(elem) { return document.getElementById(elem); } funButton1 = function() { getBYid('spanOutPut').innerHTML = "Button 1