Is there a way to get a reference to all the paragraphs or headings in a web page in JavaScript?

Posted by mattbd on Stack Overflow See other posts from Stack Overflow or by mattbd
Published on 2010-04-07T17:39:40Z Indexed on 2010/04/07 17:43 UTC
Read the original article Hit count: 158

Filed under:
|

I'm writing a simple Greasemonkey script to strip out all the images, headings and paragraphs from a web page (it's because someone wants to use images of several popular websites with the images and text removed in a presentation about branding of websites). I've figured out how to do so with images by using a for loop and the document.images array like this:

var i = 0;
var imglngth = document.images.length;

for(i=0;i<imglngth;i++)
{
    document.images[i].style.display="none";
}

However, I don't believe there's an object representing paragraphs or headers. Any suggestions as to how I could implement this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dom