title: How to Use Element ID to getElementsByClassName?
body: <p>I have a script that will <code>findElementById</code> across multiple frames and will highlight/change the text color. The script works so that when you <code>mouseover</code> each word of &quot;The quick brown fox,&quot; the word under your pointer will be red and highlighted in yellow. The same word in frame2 will be red/highlighted as well. Note that the element ids are identical to the class name(s).</p>
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;title&gt;Test&lt;/title&gt;
    &lt;script&gt;
      function hey(id)
        {document.getElementById(id).style.color = &quot;red&quot;;
        document.getElementById(id).style.backgroundColor = &quot;yellow&quot;;
        window.parent.frames[&quot;frame2&quot;].document.getElementById(id).style.color = &quot;red&quot;;
        window.parent.frames[&quot;frame2&quot;].document.getElementById(id).style.backgroundColor = &quot;yellow&quot;;} 
      function bye(id)
        {document.getElementById(id).style.color = &quot;black&quot;;
        document.getElementById(id).style.backgroundColor = &quot;white&quot;;
        window.parent.frames[&quot;frame2&quot;].document.getElementById(id).style.color = &quot;black&quot;;
        window.parent.frames[&quot;frame2&quot;].document.getElementById(id).style.backgroundColor = &quot;white&quot;;}
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;a id=&quot;w1&quot; class=&quot;w1 w4&quot; onmouseover=&quot;hey(this.id)&quot; onmouseout=&quot;bye(this.id)&quot;&gt;The&lt;/a&gt; 
    &lt;a id=&quot;w2&quot; class=&quot;w2&quot; onmouseover=&quot;hey(this.id)&quot; onmouseout=&quot;bye(this.id)&quot;&gt;quick&lt;/a&gt;
    &lt;a id=&quot;w3&quot; class=&quot;w3&quot; onmouseover=&quot;hey(this.id)&quot; onmouseout=&quot;bye(this.id)&quot;&gt;brown&lt;/a&gt; 
    &lt;a id=&quot;w4&quot; class=&quot;w1 w4&quot; onmouseover=&quot;hey(this.id)&quot; onmouseout=&quot;bye(this.id)&quot;&gt;fox&lt;/a&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  <p>Now I want to edit this script so that it takes the id and finds elements by class. For example, when you <code>mouseover</code> &quot;fox&quot; the id=&quot;w4&quot;. I want to find &quot;w4&quot; in the link's class so that both &quot;The&quot; and &quot;fox&quot; will be red/highlighted whenever either is moused over. I can't figure out how to use <code>getElementsByClassName</code> using values from the id. Any thoughts?</p>