Just as window and document objects in JS corresponds to window(?) and <body> elements in HTML, can you refer to more nested elements of the <body> simply by appending with dots(.)? (like window.document.p)
I haven’t seen it anywhere but I don’t know since I haven’t seen it anywhere. It just seemed intuitive to me that nested elements in HTML be represented as nested objects in JavaScript instead of having to getElementByID but somehow this chain seems broken after window.document
Some nested elements can be accessed diretcly using
, e.g.,
, which is an array containing all forms on the page.
In general, however, you have either to traverse the dom tree using
or access the element directly using methods like
an alike.