title: How to change dynamically height of textarea that have className?
body: <p>I tried to autoheight the textarea that have an id.
  using this code, </p>
  
  <pre><code>function init () {
  var text = document.getElementById('id1');
  function resize () {
      var clone = text.cloneNode();
      clone.className = 'clone';
      text.parentNode.insertBefore(clone, text);
      clone.style.height = 'auto';
      clone.value = text.value;
      text.style.height = (clone.scrollTop + clone.scrollHeight -20) + 'px';
      text.parentNode.removeChild(clone);
  }
  /* 0-timeout to get the already changed text */
  function delayedResize () {
      window.setTimeout(resize, 0);
  }
  observe(text, 'change',  resize);
  observe(text, 'cut',     delayedResize);
  observe(text, 'paste',   delayedResize);
  observe(text, 'drop',    delayedResize);
  observe(text, 'keydown', delayedResize);
  
  text.focus();
  text.select();
  resize();
  }
  </code></pre>
  
  <p>I change the getElementByID by getElementsByClassName. Then clone it, but it is not working.</p>
  
  <pre><code> var chs = document.getElementsByClassName("ch");
   for(var k  = 0; k &lt; chs.length;k++){
               function resize () {
                  var clone = chs[k].cloneNode();
                  clone.className = 'clone';
                  chs[k].parentNode.insertBefore(clone, chs[k]);
                  clone.style.height = 'auto';
                  clone.value = chs[k].value;
                  chs[k].style.height = (clone.scrollTop + clone.scrollHeight -20) + 'px';
                  chs[k].parentNode.removeChild(clone);
              }
              function delayedResize () {
                  window.setTimeout(resize, 0);
              }
              observe(chs[k], 'change',  resize);
              observe(chs[k], 'cut',     delayedResize);
              observe(chs[k], 'paste',   delayedResize);
              observe(chs[k], 'drop',    delayedResize);
              observe(chs[k], 'keydown', delayedResize);
              chs[k].focus();
              chs[k].select();
              resize();
      }
  </code></pre>
  
  <p>The error is Uncaught TypeError: Cannot read property 'cloneNode' of undefinedindex.html:253 resize</p>
  
  <p>All I need is make all textarea dynamically change height. Like FB feed textarea.</p>