title: Javascript toggle visibility multiple divs
body: <p><a href="http://blog.movalog.com/a/javascript-toggle-visibility/" rel="nofollow">http://blog.movalog.com/a/javascript-toggle-visibility/</a></p>
  
  <p>this is a page with some code and a script im using in my site for an image gallery, however when trying to toggle the visibility of multiple div's it only works on the first. can someone please fix it to work with multiple div's, i dont know js :)</p>
  
  <p>here is the javascript </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  &lt;!--
      function toggle_visibility(id) {
         var e = document.getElementById(id);
         if(e.style.display == 'block')
            e.style.display = 'none';
         else
            e.style.display = 'block';
      }
  //--&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>and here is the html code for the links</p>
  
  <pre><code>&lt;tr&gt;&lt;td&gt;&lt;a href="#" onclick="toggle_visibility('nyc');"&gt;New York&lt;/a&gt;&lt;/td&gt;
  &lt;td&gt;&lt;a href="#" onclick="toggle_visibility('photoshop');"&gt;Photoshop Work&lt;/td&gt;
  &lt;td&gt;&lt;a href="#" onclick="toggle_visibility('photography');"&gt;Photography&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;a href="#" onclick="toggle_visibility('art');"&gt;Art Projects&lt;/td&gt;&lt;/tr&gt;
  </code></pre>
  
  <p>wait a sec, could this not be working because it is trying to acess the properties of multiple divs via the "id" property, would it work with the class property and if so would i just change the java script where it says "id" to "class"</p>