title: Access to oldChild by replaceChild with getElementsClassName, Javascript, DOM
body: <p>How can I get access to the old Node and replace it?</p>
  
  <p>My XHTML has this structure:</p>
  
  <pre><code>&lt;table id="output"&gt;
   &lt;tr&gt;
     &lt;td&gt;Sometext&lt;/td&gt;
     &lt;td&gt;...&lt;/td&gt;
     &lt;td&gt;...&lt;td&gt;
   &lt;/tr&gt;
   &lt;tr class="CLASSNAME"&gt;
     &lt;td class="ElemKat"&gt;text&lt;/td&gt;
     &lt;td class="ELEM"&gt;...&lt;/td&gt;
     &lt;td class="EL"&gt;...&lt;/td&gt;
   &lt;/tr&gt; 
    &lt;tr class="CLASSNAME"&gt;
     &lt;td class="ElemKat"&gt;text2&lt;/td&gt;
     &lt;td class="ELEM"&gt;s&lt;/td&gt;
     &lt;td class="EL"&gt;sss&lt;/td&gt;
   &lt;/tr&gt; 
  &lt;/table&gt;
  </code></pre>
  
  <p>I have so many classes, because the elements are create dynamically and so the IDs are not a variant.</p>
  
  <p>And the function, in which the error shows up (error as a comment):</p>
  
  <pre><code>var sort=function(cmpFunc) {
  
      var table=document.getElementById("output");
      var kat=document.getElementsByClassName("ElemKat");
      var elem_kat=new Array();
          for(var i=0; i&lt;kat.length; i++) {
              elem_kat.push(kat[i]); 
          }
          var elem_kat_old=new Array();
          elem_kat_old=elem_kat;
          elem_kat.sort(cmpFunc);
  
     for(var j=0; j&lt;elem_kat.length; j++) {
      //table=elem_kat_old[j].parentNode; -&gt;No error,but no change in the output
      table.replaceChild(elem_kat[j],elem_kat_old[j]); //Node was not found
      }
      }
  </code></pre>