No title Revision 326530663566 (Wed May 06 2009 at 14:05) - Diff Link to this snippet: http://friendpaste.com/29sHyVu1J3iljnGks30yY3 Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 1234567891011121314151617181920212223242526272829// jQuery function to find all the text nodes inside an element$.fn.textNodes = function() { // array we will store all the text nodes in var ret = []; // nodes we want to skip var restricted_nodes = {'SCRIPT':1, 'NOSCRIPT':1, 'STYLE':1}; $.each(this[0].childNodes, function() { if (this.nodeType == 3 && $.trim(this.nodeValue)) { ret.push(this); } else if (!restricted_nodes.hasOwnProperty(this.nodeName)) { $.each(this.childNodes, arguments.callee); } }); return ret;}var textNodes = $('body').textNodes();var text = '';for (var i = 0; i < textNodes.length; ++i) { text += textNodes[i].nodeValue + ' ';}// text is now a string containing the full text of a webpage with no html// see http://docs.jquery.com/Release:jQuery_1.3.2#:visible.2F:hidden_Overhauled// for details on how jquery handles finding hidden elements