title: Get Element By Classname Script Not Working
body: <p>I know, it's not supported by IE, but I found a cool script online that someone was generous enough to provide for free, but I can't figure out why it's not working. I've been staring at this for hours, please point me in the right direction!</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript" src="getbyclass.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" language="javascript"&gt;
  function editToggle(toggle){
      if (toggle == "off"){
      getElementsByClassName("editp").style.display ="none";
      document.getElementById('editToggle').innerHTML="&lt;a href=\"#\" onclick=\"editToggle(\"off\"); return false;\"&gt;&gt;Edit Mode: &lt;span style=\"color:red;\"&gt;OFF&lt;/span&gt;&lt;/a&gt;";
      toggle="on";
      }else{
      getElementsByClassName("editp").style.display ="inline";
      document.getElementById('editToggle').innerHTML="&lt;a href=\"#\" onclick=\"editToggle(\"on\"); return false;\"&gt;&gt;Edit Mode: &lt;span style=\"color:green;\"&gt;on&lt;/span&gt;&lt;/a&gt;";
      toggle="off";
      }
  }
  </code></pre>
  
  <p>also:</p>
  
  <pre><code>echo "&lt;span id=\"editToggle\"&gt;&lt;a href=\"#\" onclick=\"editToggle(); return false;\"&gt;Edit Mode: &lt;span style=\"color:red;\"&gt;OFF&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;";
  </code></pre>
  
  <p>The code from <code>getbyclass.js</code> can be seen <a href="http://robertnyman.com/2008/05/27/the-ultimate-getelementsbyclassname-anno-2008/" rel="nofollow">here</a>.</p>
  
  <hr>
  
  <p>In response to the answers below, I've tried this:</p>
  
  <pre><code>function editToggle(toggle){
      var list = getElementsByClassName("editp");
      if (toggle == "off"){
      //getElementsByClassName("editp").style.display ="none";
          for (index = 0; index &lt; list.length; ++index) {
              list[index].style.display ="none";
          }
      document.getElementById('editToggle').innerHTML="&lt;a href=\"#\" onclick=\"editToggle(\"off\"); return false;\"&gt;&gt;Editfalse;\"&gt;Edit Mode: &lt;span style=\"color:red;\"&gt;OFF&lt;/span&gt;&lt;/a&gt;";
      toggle="on";
      }else{
      //getElementsByClassName("editp").style.display ="inline";
          for (index = 0; index &lt; list.length; ++index) {
              list[index].style.display ="inline";
          }
      document.getElementById('editToggle').innerHTML="&lt;a href=\"#\" onclick=\"editToggle(\"on\"); return false;\"&gt;&gt;Editfalse;\"&gt;Edit Mode: &lt;span style=\"color:green;\"&gt;on&lt;/span&gt;&lt;/a&gt;";
      toggle="off";
      }
  }
  </code></pre>
  
  <p>But it's still not working.</p>