Name
DocumentFragment — adjacent nodes and their subtrees
Inherits from
Node
Synopsis
The DocumentFragment interface represents a portion—or
fragment—of a document. More specifically, it is a list of adjacent
nodes and all descendants of each, but without any common parent
node. DocumentFragment nodes are never part of a document tree, and
the inherited parentNode property
is always null. DocumentFragment
nodes exhibit a special behavior that makes them quite useful,
however: when a request is made to insert a DocumentFragment into a
document tree, it is not the DocumentFragment node itself that is
inserted but instead each child of the DocumentFragment. This makes
DocumentFragment useful as a temporary placeholder for nodes that
you wish to insert, all at once, into a document.
You can create a new, empty DocumentFragment with Document.createDocumentFragment().
You can search for elements in a DocumentFragment with
querySelector() and querySelectorAll(), which work
just like the same methods of the Document object.
Methods
Element querySelector(string
selectors)
querySelector(string
selectors)See Document.querySelector().
NodeList querySelectorAll(string
selectors)
querySelectorAll(string
selectors)See Document.querySelectorAll().
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access