title: javascript change class of multiple inputs onclick
body: <p>I wanted to change the class of some inputs of my form having a class='mypost_title' at onclick.</p>
  
  <p>I tried this and it doesn't work</p>
  
  <pre><code>&lt;a href='' onclick='popup_mypost(e)'&gt;change me&lt;/a&gt;
  &lt;a href='' id=edit-href onclick='popup_mypost(e)'&gt;back me&lt;/a&gt;
  
  &lt;script&gt;
      function popup_mypost(e) 
      {
          var inputs = document.getElementsByClassName("mypost_title");
          for(var i = 0; i &lt; inputs.length; i++) 
              {
              inputs[i].className = "change";
              }
  
          var edit_href = document.getElementById("edit-href");
          edit_href.onclick = function()
          {
              var inputs = document.getElementsByClassName("change");
              for(var i = 0; i &lt; inputs.length; i++) 
                  {
                  inputs[i].className = "mypost_title";
                  }
          }
      }
  &lt;/script&gt;
  </code></pre>