This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

body

Summary

Gets or sets the body element of the document.

Property of dom/Documentdom/Document

Syntax

var bodyElement = document.body;
document.body = newBodyElement;

Return Value

Returns an object of type DOM NodeDOM Node

The body element of the document.

Examples

//get the document's body content, append to it, set new content
function appendBody() {
    var bod = document.body.innerHTML;
    bod += "<p>That's all, folks!</p>";
    document.body.innerHTML = bod;
}

Usage

 Use this property to get the body element of the document, or to replace it with a new body element.

Related specifications

DOM Level 2 HTML
Recommendation
W3C HTML5
Working Draft
WHATWG HTML
Living Standard

Attributions