title: Toggle Visibility By Class
body: <p>Hi can anyone help me please.</p>
  
  <p>How can i use Toggle Visibility by class instead of a id for example.</p>
  
  <p>The Button</p>
  
  <pre><code>&lt;a href="javascript:void(0);" onclick="toggle_visibility('trailer');"&gt;Trailer&lt;/a&gt;
  </code></pre>
  
  <p>Then this.</p>
  
  <pre><code>&lt;div class="trailer" style="display:none"&gt;{include file="trailer.tpl"}&lt;/div&gt;
  </code></pre>
  
  <p>So how can i modify this javascript to work with classes.</p>
  
  <pre><code>{literal}
  &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;                
  {/literal}  
  </code></pre>
  
  <p>So what would javascript by for this please help.</p>