NodeList objects are collections of nodes, usually returned by properties such as Node.childNodes and methods such as document.querySelectorAll().

interface NodeList {
    length: number;
    forEach(callbackfn: ((value: Node, key: number, parent: NodeList) => void), thisArg?: any): void;
    item(index: number): null | Node;
    [index: number]: Node;
}

层级 (查看完整内容)

可索引

  • [index: number]: Node

属性

方法

属性

length: number

Returns the number of nodes in the collection.

方法

  • Performs the specified action for each node in an list.

    参数

    • callbackfn: ((value: Node, key: number, parent: NodeList) => void)

      A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.

        • (value, key, parent): void
        • 参数

          返回 void

    • 可选thisArg: any

      An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

    返回 void

  • Returns the node with index index from the collection. The nodes are sorted in tree order.

    参数

    • index: number

    返回 null | Node