TreeWalker.parentNode()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
La méthode TreeWalker.parentNode()
déplace le Node
courant vers le premier noeud ancêtre visible dans l'ordre du document et renvoie le noeud trouvé. Si aucun noeud n'existe ou s'il est au-dessus du noeud racine du TreeWalker
, elle renvoie null
et le noeud actuel reste inchangé.
Syntaxe
js
node = treeWalker.parentNode();
Exemple
js
var treeWalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{
acceptNode: function (node) {
return NodeFilter.FILTER_ACCEPT;
},
},
false,
);
var node = treeWalker.parentNode(); // returns null as there is no parent
Spécifications
Specification |
---|
DOM Standard # dom-treewalker-parentnode |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
parentNode |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Voir aussi
- L'interface
TreeWalker
à laquelle elle appartient.