When searching for one or more dom elements using document.getElementById
, a single dom element is returned with typeof(node) -> "object"
.
If no dom element is found for the query, a null
object is returned which also gives typeof(node) -> "object"
.
caseOne = document.getElementById('contentSub')
-> <div id="contentSub">
typeof(caseOne)
-> "object"
caseTwo= document.getElementById('qwert')
-> null
typeof(caseTwo)
-> "object"
How to check whether a call to document.getElementById
has been successful, in the sense that a dom element has been returned that may be further processed?