Since: 8.4

interface ParentNode (View source)

This is the modern, spec-compliant equivalent of DOMParentNode.

Methods

void
append(Node|string ...$nodes)

Appends nodes after the last child node

void
prepend(Node|string ...$nodes)

Prepends nodes before the first child node

void
replaceChildren(Node|string ...$nodes)

Replace children in node

Element|null
querySelector(string $selectors)

Returns the first element that matches the CSS selectors

querySelectorAll(string $selectors)

Returns a collection of elements that match the CSS selectors

Details

void append(Node|string ...$nodes)

Appends nodes after the last child node

Appends one or many nodes to the list of children after the last child node.

Parameters

Node|string ...$nodes

The nodes to append. Strings are automatically converted to text nodes.

Return Value

void

No value is returned.

void prepend(Node|string ...$nodes)

Prepends nodes before the first child node

Prepends one or many nodes to the list of children before the first child node.

Parameters

Node|string ...$nodes

The nodes to prepend. Strings are automatically converted to text nodes.

Return Value

void

No value is returned.

void replaceChildren(Node|string ...$nodes)

Replace children in node

Parameters

Node|string ...$nodes

The nodes replacing the children. Strings are automatically converted to text nodes.

Return Value

void

No value is returned.

Element|null querySelector(string $selectors)

Returns the first element that matches the CSS selectors

Returns the first element that matches the CSS selectors specified in selectors.

Parameters

string $selectors

A string containing one or more CSS selectors.

Return Value

Element|null

Returns the first Dom\Element that matches selectors. Returns null if no element matches.

Exceptions

DOMException

NodeList querySelectorAll(string $selectors)

Returns a collection of elements that match the CSS selectors

Returns a collection of elements that match the CSS selectors specified in selectors.

Parameters

string $selectors

Return Value

NodeList