How to change text color using javascript for loop?
<p><strong>When someone click on the text it change to red color and click on the other text return to black color.
I have make an example like below but how to make it shorter using for loop?</strong></p>

<pre><code>    &lt;html&gt;
    &lt;head&gt;
    &lt;title&gt;My little test page&lt;/title&gt;
    &lt;/head&gt;
    &lt;body id="body"&gt;
        &lt;div id="myid"&gt;Hello Here !!&lt;/div&gt;&lt;br&gt;
        &lt;div id="myid2"&gt;Hello There !!&lt;/div&gt;&lt;br&gt;
        &lt;div id="myid3"&gt;Hello !!&lt;/div&gt;&lt;br&gt;
        ......many div......
    &lt;/body&gt;
    &lt;/html&gt;

    &lt;script language="javascript"&gt;
    function changeColor1() {
    document.getElementById("myid").className = "red";
    document.getElementById("myid2").className = "";
    document.getElementById("myid3").className = "";
    }

    function changeColor2() {
    document.getElementById("myid").className = "";
    document.getElementById("myid2").className = "red";
    document.getElementById("myid3").className = "";
    }

    function changeColor3() {
    document.getElementById("myid").className = "";
    document.getElementById("myid2").className = "";
    document.getElementById("myid3").className = "red";
    }

    function init() {
    document.getElementById("myid").onclick = changeColor1;
    document.getElementById("myid2").onclick = changeColor2;
    document.getElementById("myid3").onclick = changeColor3;
    }

    window.onload = init();
    &lt;/script&gt;
</code></pre>
