I want to retrieve all the nodes present in particular DIV element.see the below test page (firefox)
New Document <
If you don't care about IE, you could avoid the recursive approach and possibly improve performance (untested) by using a TreeWalker using document.createTreeWalker:
function getCommentNodes(containerNode) {
var treeWalker = document.createTreeWalker(containerNode,
NodeFilter.SHOW_COMMENT, null, false);
var comments = [];
while (treeWalker.nextNode()) {
comments.push(treeWalker.currentNode);
}
return comments;
}
console.log(getCommentNodes(document.body));