Skip to content

Function: getAllElements() ​

Overload 1 ​

getAllElements<K>(tag): HTMLElementTagNameMap[K][]

Defined in: dom.ts:57

Returns all elements matching the given tag name, or an empty array if none exist.

Type Parameters ​

K ​

K extends keyof HTMLElementTagNameMap

Parameters ​

tag ​

K

The HTML tag name to search for.

Returns ​

HTMLElementTagNameMap[K][]

Returns an array of all found elements, or an empty array.

Example ​

ts
// HTML
<p>First</p>
<p>Second</p>
// JS
const paragraphs = facile.getAllElements('p');

Overload 2 ​

getAllElements<T>(selector): T[]

Defined in: dom.ts:71

Returns all elements matching the given CSS selector, or an empty array if none exist.

Type Parameters ​

T ​

T extends Element = Element

The expected element type. Uses Element by default.

Parameters ​

selector ​

string

A CSS selector string.

Returns ​

T[]

Returns an array of all found elements, or an empty array.

Example ​

ts
// HTML
<p class="text">First</p>
<p class="text">Second</p>
// JS
const paragraphs = facile.getAllElements('.text');