Javascript toggle function: change text and alter class style
<p>I have a really simple function that should:</p>

<ul>
<li>change the wording (from expand to collapse)</li>
<li>change the style (visibility) for a class</li>
</ul>

<p>It sorta works but really not</p>

<pre><code>function toggle_expansion(id) {
var e = document.getElementById(id);
var es =getElementsByClass('expansion');
if (e.innerHTML ='expand all')  {        
   e.innerHTML ='collapse all';
   for(i=0; i&lt;es.length; i++) 
   {es[i].style.display = 'none';}
  }  
else {       
   e.innerHTML ='expand all';
   for(i=0; i&lt;es.length; i++) 
   {es[i].style.display = 'block';}
  }
}
</code></pre>

<p>and the html:</p>

<pre><code>&lt;a href='#nogo' onclick="toggle_expansion('expand');"&gt;&lt;div id='expand'&gt;expand all&lt;/div&gt;&lt;/a&gt;
</code></pre>

<p>The text change works the first time it's clicked but only the one time and the class style change doesn't work (although it has worked in other snippets).</p>

<p>There are no errors thrown - it just doesn't work...Anyone have any ideas?</p>
