One of the following:
Examples// Given this HTML: <body id="oldBodyElement"></body>
alert(document.body.id); // "oldBodyElement"
const newBodyElement = document.createElement("body");
newBodyElement.id = "newBodyElement";
document.body = newBodyElement;
alert(document.body.id); // "newBodyElement"
Notes
document.body
is the element that contains the content for the document. In documents with <body>
contents, returns the <body>
element, and in frameset documents, this returns the outermost <frameset>
element.
Though the body
property is settable, setting a new body on a document will effectively remove all the current children of the existing <body>
element.
Loadingâ¦
See alsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5