TreeWalker.firstChild()
La méthode TreeWalker.firstChild()
déplace le Node
courant vers le premier enfant visible du noeud courant et renvoie l'enfant trouvé. Il déplace aussi le noeud courant vers cet enfant. Si aucun enfant n'existe, elle renvoie null
et le noeud courant n'est pas modifié.
Syntaxe
node = treeWalker.firstChild;
Exemple
var treeWalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{ acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
false
);
var node = treeWalker.firstChild(); // renvoie le premier enfant de l'élément racine ou null si aucun
Spécifications
Spécification | Statut | Commentaire |
---|---|---|
DOM La définition de 'TreeWalker.firstChild' dans cette spécification. |
Standard évolutif | Pas de changement de Document Object Model (DOM) Level 2 Traversal and Range Specification |
Document Object Model (DOM) Level 2 Traversal and Range Specification La définition de 'TreeWalker.firstChild' dans cette spécification. |
Obsolete | Définition initiale. |
Compatibilité des navigateurs
BCD tables only load in the browser
Voir aussi
- L'interface
TreeWalker
à laquelle elle appartient.