DocumentFragment Class
https://dom.spec.whatwg.org/#interface-documentfragment
public class DocumentFragment : Node, INonElementParentNode, IParentNode- Inheritance
NodeDocumentFragment- Implements
Constructors
| Name | Description |
|---|---|
| DocumentFragment() | Creates an empty document fragment owned by the current global document. |
DocumentFragment()
DocumentFragment.csCreates an empty document fragment owned by the current global document.
public DocumentFragment()Properties
| Name | Description |
|---|---|
| ChildElementCount | Gets the number of child elements. |
| Children | Gets the live collection of the child elements. |
| FirstElementChild | Gets the first child that is an element, or null when there is none. |
| LastElementChild | Gets the last child that is an element, or null when there is none. |
| NodeName | Gets the node name of a document fragment, which is #document-fragment. |
| NodeType | Gets the node type of a document fragment, which is 11 (DOCUMENT_FRAGMENT_NODE). |
| TextContent | Gets or sets the concatenation of the text of the descendant text nodes; setting it replaces all the children. |
ChildElementCount
Mixins.Members.csGets the number of child elements.
public uint ChildElementCount { get; }Children
Mixins.Members.csGets the live collection of the child elements.
public HtmlCollection Children { get; }FirstElementChild
Mixins.Members.csGets the first child that is an element, or null when there is none.
public Element? FirstElementChild { get; }LastElementChild
Mixins.Members.csGets the last child that is an element, or null when there is none.
public Element? LastElementChild { get; }NodeName
DocumentFragment.csNodeType
DocumentFragment.csTextContent
DocumentFragment.csMethods
| Name | Description |
|---|---|
| Append(ReadOnlySpan<NodeOrString>) | Inserts the nodes after the last child, converting the strings into text nodes. |
| GetElementById(string) | Returns the first descendant element, in tree order, whose ID is the given value, or null. |
| MoveBefore(Node, Node?) | Moves the node, preserving its state, before the given child (or to the end when the child is null). |
| Prepend(ReadOnlySpan<NodeOrString>) | Inserts the nodes before the first child, converting the strings into text nodes. |
| QuerySelector(SelectorList) | Returns the first descendant element, in tree order, that matches the parsed selector list, or null. |
| QuerySelector(string) | Returns the first descendant element, in tree order, that matches the selectors, or null. |
| QuerySelector<T>(SelectorList) | Returns the first descendant, in tree order, that is a T and matches the parsed selector. |
| QuerySelector<T>(string) | Returns the first descendant, in tree order, that is a T and matches the selector. |
| QuerySelectorAll(SelectorList) | Returns the descendant elements, in tree order, that match the parsed selector list. |
| QuerySelectorAll(string) | Returns the descendant elements, in tree order, that match the selectors. |
| QuerySelectorAll<T>(SelectorList) | Returns the descendants, in tree order, that are a T and match the parsed selector. |
| QuerySelectorAll<T>(string) | Returns the descendants, in tree order, that are a T and match the selector. |
| ReplaceChildren(ReadOnlySpan<NodeOrString>) | Replaces all the children with the given nodes, converting the strings into text nodes. |
Append(ReadOnlySpan<NodeOrString>)
Mixins.Members.csInserts the nodes after the last child, converting the strings into text nodes.
public void Append(params scoped ReadOnlySpan<NodeOrString> nodes)Parameters
See also
GetElementById(string)
Mixins.Members.csReturns the first descendant element, in tree order, whose ID is the given value, or null.
MoveBefore(Node, Node?)
Mixins.Members.csPrepend(ReadOnlySpan<NodeOrString>)
Mixins.Members.csInserts the nodes before the first child, converting the strings into text nodes.
public void Prepend(params scoped ReadOnlySpan<NodeOrString> nodes)Parameters
See also
QuerySelector overloads
QuerySelector(SelectorList)
Mixins.Members.csReturns the first descendant element, in tree order, that matches the parsed selector list, or null.
public Element? QuerySelector(SelectorList selectors)QuerySelector(string)
Mixins.Members.csReturns the first descendant element, in tree order, that matches the selectors, or null.
QuerySelector<T>(SelectorList)
Mixins.Members.csReturns the first descendant, in tree order, that is a T and matches the parsed selector.
public T? QuerySelector<T>(SelectorList selectors) where T : ElementQuerySelector<T>(string)
Mixins.Members.csQuerySelectorAll overloads
QuerySelectorAll(SelectorList)
Mixins.Members.csReturns the descendant elements, in tree order, that match the parsed selector list.
public NodeList QuerySelectorAll(SelectorList selectors)QuerySelectorAll(string)
Mixins.Members.csReturns the descendant elements, in tree order, that match the selectors.
QuerySelectorAll<T>(SelectorList)
Mixins.Members.csReturns the descendants, in tree order, that are a T and match the parsed selector.
public IReadOnlyList<T> QuerySelectorAll<T>(SelectorList selectors) where T : ElementQuerySelectorAll<T>(string)
Mixins.Members.csReturns the descendants, in tree order, that are a T and match the selector.
public IReadOnlyList<T> QuerySelectorAll<T>(string selectors) where T : ElementReplaceChildren(ReadOnlySpan<NodeOrString>)
Mixins.Members.csReplaces all the children with the given nodes, converting the strings into text nodes.
public void ReplaceChildren(params scoped ReadOnlySpan<NodeOrString> nodes)