Skip to content

Instantly share code, notes, and snippets.

@ymrl
Created March 3, 2011 14:41
Show Gist options
  • Save ymrl/852859 to your computer and use it in GitHub Desktop.
Save ymrl/852859 to your computer and use it in GitHub Desktop.
var getText = function(n){
var c = n.childNodes;
for(var i=0;i<c.length;i++){
var m = c[i];
if(m.nodeType==1 && !m.tagName.match(/^script|style$/i)){
getText(m);
}else if(m.nodeType==3 && !m.textContent.match(/^\s*$/)){
console.log(m.textContent);
}
}
}
getText(document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment