title: Dynamic show/hide div with javascript not working
body: <p>I have a basic show/hide javascript that works, as long as i don't make it dynamic and make sure of a parameter. I would appreciate a lot if anyone could help me figure out why the dynamic version doesn't work.</p>
  
  <p>Working code:<br>
  <strong>javascript</strong>   </p>
  
  <pre><code>function togglesDiv(){  
    var catdiv = document.getElementById("addNewCat");  
    if(catdiv.style.display == ""){  
      catdiv.style.display = "none";  
    } else {  
      catdiv.style.display = "";  
    }  
  }  
  </code></pre>
  
  <p><strong>html</strong> </p>
  
  <pre><code>&lt;span onclick="togglesDiv();"&gt;Add new category&lt;/span&gt;  
  &lt;div id="addNewCat" style="display: none;"&gt;  
  lalala  
  &lt;/div&gt;
  </code></pre>
  
  <p>Non working code:<br>
  <strong>javascript</strong> </p>
  
  <pre><code>function togglesDiv(divsId){  
    var catdiv = document.getElementById("divsId");
    if(catdiv.style.display == ""){  
      catdiv.style.display = "none";  
    } else {  
      catdiv.style.display = "";  
    }  
  }  
  </code></pre>
  
  <p><strong>html</strong>  </p>
  
  <pre><code>&lt;span onclick="togglesDiv(addNewCat);"&gt;Add new category&lt;/span&gt;  
  &lt;div id="addNewCat" style="display: none;"&gt;  
  lalala  
  &lt;/div&gt;
  </code></pre>