Remove all the text from a web page using Javascript
<h2>
(function(){
var a = document.querySelectorAll("body *")
, i = a.length
, child
, children
, x
;while(i--){ children = a[i].childNodes, x = children.length; while(x--){ var child = children[x]; if(a[i].hasChildNodes() && child.nodeType === 3) { child.nodeValue = ""; }; }; if(a[i].tagName.toLowerCase() === "input" || a[i].tagName.toLowerCase() === "textarea"){ a[i].value = ""; a[i].setAttribute("placeholder", ""); } else if(a[i].tagName.toLowerCase() === "iframe"){ a[i].style.visibility = "hidden"; }; };
})();
</h2></pre>
it's on Github
Written by jzazove
Related protips
1 Response
this is great... but pretty useless :))
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#