Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Document
  4. body

Document: body property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since May 2018.

TheDocument.body property represents the<body> or<frameset> node of the current document, ornull if no such element exists.

Value

One of the following:

Examples

js
// Given this HTML: <body></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 thebody property is settable, setting a new body on a documentwill effectively remove all the current children of the existing<body> element.

Specifications

Specification
HTML
# dom-document-body-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp