简体   繁体   English

javascript getElementsByTagName实现中的DOM遍历

[英]DOM traversal in implementations of javascript getElementsByTagName

What method(s) of DOM (tree) traversal do implementations of the javascript function getElementsByTagName use? javascript函数getElementsByTagName的实现使用DOM(树)遍历的哪些方法? I ask because I'd like to be sure that the array returned by getElementsByTagName contains DOM elements in an order roughly from the top of the document to the bottom, which would be the case in a depth-first search of the DOM tree, for instance. 我问,是因为我想确保getElementsByTagName返回的数组包含DOM元素的顺序大致是从文档顶部到底部,在DOM树的深度优先搜索中就是这种情况,实例。

You can find out stuff like this by reading the specification 您可以通过阅读规范来查找类似的内容

getElementsByTagName getElementsByTagName

Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree . 返回具有给定标记名称的所有后代Element的NodeList, 其顺序是在此Element树的预遍历中遇到它们的顺序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM