How do I verify the existence of an object in JavaScript?
The following works:
if (!null) alert(\"GOT HERE\");
But this throws a
I've just tested the typeOf examples from above and none worked for me, so instead I've used this:
btnAdd = document.getElementById("elementNotLoadedYet"); if (btnAdd) { btnAdd.textContent = "Some text here"; } else { alert("not detected!"); }