title: How I can change child elements order in JS?
body: <p>I have this html:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;
              Set right order
          &lt;/td&gt;
          &lt;td&gt;
              &lt;span style = "display: block;"&gt;asd | &lt;a href = '#' onclick = "moveChoiceTo(this, -1);"&gt;&amp;uarr;&lt;/a&gt;&lt;a href = '#' onclick = "moveChoiceTo(this, 1);"&gt;&amp;darr;&lt;/a&gt;&lt;/span&gt;
              &lt;span style = "display: block;"&gt;dsa | &lt;a href = '#' onclick = "moveChoiceTo(this, -1);"&gt;&amp;uarr;&lt;/a&gt;&lt;a href = '#' onclick = "moveChoiceTo(this, 1);"&gt;&amp;darr;&lt;/a&gt;&lt;/span&gt;
              &lt;span style = "display: block;"&gt;qwe | &lt;a href = '#' onclick = "moveChoiceTo(this, -1);"&gt;&amp;uarr;&lt;/a&gt;&lt;a href = '#' onclick = "moveChoiceTo(this, 1);"&gt;&amp;darr;&lt;/a&gt;&lt;/span&gt;
              &lt;span style = "display: block;"&gt;ewq | &lt;a href = '#' onclick = "moveChoiceTo(this, -1);"&gt;&amp;uarr;&lt;/a&gt;&lt;a href = '#' onclick = "moveChoiceTo(this, 1);"&gt;&amp;darr;&lt;/a&gt;&lt;/span&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And this JS:</p>
  
  <pre><code>function moveChoiceTo(elem_choice, direction)
  {
      var curr_index = -1; //index of elem that we should move
      var td = elem_choice.parentElement.parentElement; //link to TD
  
      for (var i = 0; i &lt; td.children.length; i++) //determine index of elem that called this function
          if (td.children[i].children[0] == elem_choice)
          {
              curr_index = i;
              break;
          }
  
      if (curr_index == -1)
          return;
  
      if (curr_index == 0 &amp;&amp; direction &lt; 0) //if nowhere to move
          return;
  
      if (curr_index == td.children.length - 1 &amp;&amp; direction &gt; 0) //if nowhere to move
          return;
  
      var curr_child = td.children[curr_index]; //save current elem into temp var
      td.children.splice(curr_index, 1); //here I getting exception that splice isn't supported by object, but arent this is array?
      td.children.splice(curr_index + direction, 0, curr_child); //attempt to insert it
  }
  </code></pre>
  
  <p>I getting exception that <code>splice</code> isn't supported, but this supposed to be an array and support this method?
  What other ways I have to change children order?</p>