Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Crockfordian walk the dom
- var walkTheDOM = function walk(node, func) {
- func(node);
- node = node.firstChild;
- while (node) {
- walk(node, func);
- node = node.nextSibling;
- }
- };
- var getTextNodes = function(node,func){
- walkTheDOM(document.body,function(node){
- if(node.nodeType==3){
- func(node);
- }
- });
- };
- getTextNodes(document.body,function(node){
- console.log(node.nodeValue);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement