Skip to content

Type Editor


Type Editor / @type-editor/dom-util / dom-index / domIndex

Function: domIndex()

ts
function domIndex(node): number;

Defined in: dom-index.ts:13

Gets the index of a DOM node within its parent's child list.

Parameters

ParameterTypeDescription
nodeNodeThe DOM node to find the index of

Returns

number

The zero-based index of the node among its siblings

Example

typescript
const element = document.getElementById("myElement");
const index = domIndex(element); // Returns position among siblings