title: Getting an error: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'
body: <p>I've seen people with this problem before here but none of the answers helped me understand my issue better.</p>
  
  <p>I have a sorting function that isn't sorting elements attached to the DOM, but giving an error in the console: <code>Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.</code> </p>
  
  <p>I don't understand why beyond the fact that it can't append the objects to the DOM because they're of different types. </p>
  
  <pre><code>function sorting(){
    $('#sort_by a').click(function(e){
      var sortAttr = $(this).attr('href').slice(1);
      e.preventDefault()
  
      var bands = $('#results').children();
  
      bands.sort(function (a, b) {
        if ($(a).attr(sortAttr) &gt; $(b).attr(sortAttr)){
        return 1;
      }
      if ($(b).attr(sortAttr) &gt; $(a).attr(sortAttr)){
        return -1;
      }
      return 0;
    });
  
    var appendAnim = function(items, index){
      $(items[index]).hide();
      $(items[index]).fadeIn(500);
  
      document.getElementById('results').appendChild(items[index])
  
      if(index &lt; items.length ){
        appendAnim(items,index + 1);
      }
    }
  
    appendAnim(bands,0)
    return false;
  
    });
  };
  </code></pre>