跳转到主要内容

Document: rootElement property

Document.rootElement returns the Element that is the root element of the document if it is an svg element, otherwise null. It is deprecated in favor of Document.documentElement, which returns the root element for all documents.

Value

For SVG elements, the Element that is the root element of the document; otherwise null.

If the document is a non-empty SVG document, then the rootElement will be an SVGSVGElement, identical to the documentElement.

Specifications

Browser compatibility