NodeList.keys()
La méthode NodeList.keys() renvoie un itérateur permettant de parcourir toutes les clés contenues dans cet objet. Les clés sont des unsigned integer (entier non signé).
Syntaxe
js
nodeList.keys();
Valeur retournée
Renvoie un itérateur.
Exemple
js
var node = document.createElement("div");
var kid1 = document.createElement("p");
var kid2 = document.createTextNode("hey");
var kid3 = document.createElement("span");
node.appendChild(kid1);
node.appendChild(kid2);
node.appendChild(kid3);
var list = node.childNodes;
// Utilisation de for..of
for(var key of list.keys()) {
   console.log(key);
}
Le résultat est :
0 1 2
Spécifications
No specification found
No specification data found for api.NodeList.keys.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.
Compatibilité des navigateurs
BCD tables only load in the browser