Created
March 1, 2012 11:12
-
-
Save yuest/1949131 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
document.getComments = function getComments(pnode, result) { | |
pnode = pnode || document.documentElement | |
result = result || [] | |
var cnodes = pnode.childNodes | |
, cnode, i | |
for (i = -1; (cnode = cnodes[++i]); ) { | |
if (cnode.nodeType !== 8) { | |
getComments(cnode, result) | |
} else { | |
result.push(cnode) | |
} | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello world