I wrote Javascript for many years, but now I understand that I don’t quite understand how these "HTML-y" methods interact with the DOM.
My guess is that when HTML is interpreted in the DOM, the browser stores links to which HTML element has become the DOM node.
So, for .getElementByIdwhen you select an item, the browser returns the corresponding node link by link. Why not just do it .getNodeByIdthen or rather?
My guess is what .innerHTMLthe browser interprets in the DOM at runtime. However, in older browsers, such as IE7, .innerHTMLit cannot be used to create table nodes. This tells me that it was originally intended only to change the text properties of existing nodes, but then it seems strange that it exists at all, and we do not just use it .innerText.
I guess I am just confused by some kind of Javascript story.
source
share