Help! How do you change the style of all the HTML elements of a certain type via script??? For example, if I wanted all paragraph elements in a document to have blue writing I just add the following to the HTML


<style>
p {color:blue}
</style>

Now, how would I do that with script such that if a user clicked on something, a function would fire that would change all the paragraphs or any other element type of interest blue. I know how to do it for a single element, just not all the elements of a certain type. For example, the following would turn the p1 paragraph blue.

<script>
function turnblue()
{

p1.style.color=”blue”

}
</script>

<html>
<p id=main onclick=”turnblue()”>click here to turn p1 paragraph blue

<p id=p1> paragraph p1
<p id=p2> paragraph p2
<p id=p3> paragraph p3
<p id=p4> paragraph p4
<p id=p5> paragraph p5
<p id=p6> paragraph p6
<p id=p7> paragraph p7
<p id=p8> paragraph p8

</html>

Now, how would I change all paragraphs blue in the function. Thanks very much in advance.
KBH