Created
June 10, 2011 19:54
-
-
Save ohnishiakira/1019637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* http://www.w3.org/TR/ElementTraversal/ にある | |
* - firstElementChild | |
* - nextElementSibling | |
* - childElementCount | |
* を使ったサンプル | |
*/ | |
function traverseTree(element, indent) { | |
var tagName = element.tagName; | |
var child = element.firstElementChild; | |
var childCount = element.childElementCount; | |
console.log(indent + tagName); | |
while (child) { | |
traverseTree(child, indent + " "); | |
child = child.nextElementSibling; | |
} | |
} | |
var time = 0; | |
time = new Date(); | |
traverseTree(document.body, ""); | |
time = new Date() - time; | |
console.log("total time: " + time); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment