Created
February 12, 2012 12:57
-
-
Save ziyadbasheer/1808350 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function domTreeTraverse(element) { | |
| var lead = document.getElementsByTagName(element); | |
| console.log(lead); | |
| var OpenList = new Array(); | |
| var depth = 0; | |
| var pdepth = { | |
| "One" : 0, | |
| "Two" : 0, | |
| "Three" : 0, | |
| "Four" : 0, | |
| }; | |
| //if (lead.hasChildNodes() == true) { | |
| OpenList.push(lead); | |
| for (var i = 0; i < lead.ChildNodes.length; i++) { | |
| if (lead.ChildNodes.item(i) = "p" ) { | |
| pdepth["One"]+= 1; | |
| }; | |
| }; | |
| //}; | |
| //else { | |
| // console.log("It has no child nodes"); | |
| //}; | |
| console.log(pdepth); | |
| }; | |
| domTreeTraverse("article"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment