Suppose I have a simple html code sonsisiting a parent div
and child span
element as:
<div id="my_div"><span> Nothin' but the G thang </span></div>
It is said that every element in html DOM is an object. So we can select child objects as parent.child
. E.g. window.document
, window.document.body
, window.document.head
etc then my question is why does document.getElementById("my_div").span
return undefined?
Similarly window.document.body
works but I can't go one level down after that with window.document.body.div
.