Interface ParentNode
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
Element is the most general base class from which all element objects (i.e., objects that represent elements) in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element.
[Value("ParentNode")]
public interface ParentNode
Remarks
For example, the HTMLElement interface is the base interface for HTML elements. Similarly, the SVGElement interface is the basis for all SVG elements, and the MathMLElement interface is the base interface for MathML elements. Most functionality is specified further down the class hierarchy.
Languages outside the realm of the Web platform, like XUL through the XULElement interface, also implement Element.
Properties
ChildElementCount
The Element.childElementCount read-only property
returns the number of child elements of this element.
[Value("childElementCount")]
ulong ChildElementCount { get; }
Property Value
Remarks
-Document.ChildElementCount
-DocumentFragment.ChildElementCount
Children
The read-only children property returns a live HTMLCollection
which contains all of the child Element of the element upon which it was called.
[Value("children")]
HTMLCollection Children { get; }
Property Value
- HTMLCollection
An HTMLCollection which is a live, ordered collection of the DOM
elements which are children ofnode. You can access the
individual child nodes in the collection by using either the
HTMLCollection.Item method on the collection, or by using
JavaScript array-style notation.If the element has no element children, thenchildrenis an empty list with alengthof0.
Remarks
Element.children includes only element nodes. To get all child nodes, including non-element nodes like text and comment nodes, use ChildNodes.
FirstElementChild
The Element.firstElementChild read-only property
returns an element's first child Element, or null if there
are no child elements.
[Value("firstElementChild")]
Element? FirstElementChild { get; }
Property Value
Remarks
Element.firstElementChild includes only element nodes.
To get all child nodes, including non-element nodes like text and comment nodes, use FirstChild.
-Element.NextElementSibling
-Element.LastElementChild
LastElementChild
The Element.lastElementChild read-only property
returns an element's last child Element, or null if there
are no child elements.
[Value("lastElementChild")]
Element? LastElementChild { get; }
Property Value
Remarks
Element.lastElementChild includes only element nodes.
To get all child nodes, including non-element nodes like text and comment nodes, use LastChild.
-Element.PreviousElementSibling
-Element.FirstElementChild
Methods
Append(params Union29[])
The Element.append() method
inserts a set of Node objects or strings after
the last child of the Element. Strings
are inserted as equivalent Text nodes.
[Value("append")]
GlobalObject.Undefined Append(params Union29[] nodes)
Parameters
nodesUnion29[]
Returns
Remarks
Differences from AppendChild(Node):
-Element.Prepend
-AppendChild(Node)
-Element.After
-InsertAdjacentElement(string, Element)
-NodeList
Prepend(params Union28[])
The Element.prepend() method inserts a set of
Node objects or strings before the first child
of the Element. Strings are inserted as
equivalent Text nodes.
[Value("prepend")]
GlobalObject.Undefined Prepend(params Union28[] nodes)
Parameters
nodesUnion28[]
Returns
Remarks
-Element.Append
-AppendChild(Node)
-InsertBefore(Node, Node?)
-Element.Before
-InsertAdjacentElement(string, Element)
-NodeList
QuerySelector(string)
The querySelector() method of the Element
interface returns the first element that is a descendant of the element on which it is
invoked that matches the specified group of selectors.
[Value("querySelector")]
Element? QuerySelector(string selectors)
Parameters
selectorsstring
Returns
- Element
The first descendant element of
baseElementwhich matches the specified
group ofselectors. The entire hierarchy of elements is considered when
matching, including those outside the set of elements includingbaseElement
and its descendants; in other words,selectorsis first applied to the
whole document, not thebaseElement, to generate an initial list of
potential elements. The resulting elements are then examined to see if they are
descendants ofbaseElement. The first match of those remaining elements is
returned by thequerySelector()method.If no matches are found, the returned value isnull.
Remarks
-Locating DOM elements using selectors
-Attribute selectors in the CSS
Guide
-Attribute selectors in the MDN Learning Area
-Element.QuerySelectorAll
-Document.QuerySelector and
Document.QuerySelectorAll
-DocumentFragment.QuerySelector and
DocumentFragment.QuerySelectorAll
-Other methods that take selectors: Closest(string) and
Matches(string).
QuerySelectorAll(string)
The Element method querySelectorAll()
returns a static (not live) NodeList representing a list of elements
matching the specified group of selectors which are descendants of the element on which
the method was called.
[Value("querySelectorAll")]
NodeList QuerySelectorAll(string selectors)
Parameters
selectorsstring
Returns
- NodeList
A non-live NodeList containing one Element object for
each descendant node that matches at least one of the specified selectors. The elements are in document order — that is, parents before children, earlier siblings before later siblings.NOTE
If the specifiedselectorsinclude a CSS pseudo-element, the returned list
is always empty.
Remarks
-Locating DOM elements using selectors
-Attribute selectors in the CSS
Guide
-Attribute selectors in the MDN Learning Area
-Element.QuerySelector
-Document.QuerySelector and
Document.QuerySelectorAll
-DocumentFragment.QuerySelector and
DocumentFragment.QuerySelectorAll
QuerySelector<T>(string)
[To("FirstCharToLowerCase")]
T? QuerySelector<T>(string selectors) where T : Element
Parameters
selectorsstring
Returns
- T
Type Parameters
T
ReplaceChildren(params Union30[])
The Element.replaceChildren() method replaces the
existing children of a Node with a specified new set of children. These
can be string or Node objects.
[Value("replaceChildren")]
GlobalObject.Undefined ReplaceChildren(params Union30[] nodes)
Parameters
nodesUnion30[]
Returns
Remarks
-Element.Prepend
-Element.Append
-NodeList