title: Uncaught HierarchyRequestError: Failed to append the node
body: <p>I have a problem in appending a content to a particular node .
  Here is my Jsfidde <a href="http://jsfiddle.net/usezpkj2/7/" rel="nofollow noreferrer">http://jsfiddle.net/usezpkj2/7/</a></p>
  <p>I have a main list</p>
  <blockquote>
  <p>Project1</p>
  <p>Project2</p>
  </blockquote>
  <p>Inside the Project1 and project2 there are some list items inside a <code>&lt;ul class=hiddendivcontent</code> which is hidden and when clicking on the <code>glyhicon-chevron-down</code> , the list will be shown. Here is the code for that:</p>
  <pre><code>$(&quot;.glyphicon &quot;).click( function ( e ){ 
     e.preventDefault() // prevent default action - hash doesn't appear in url
      var target = $(e.target);
      if(target.hasClass(&quot;glyphicon-chevron-right&quot;)){
      $(e.target).toggleClass('glyphicon-chevron-right glyphicon-chevron-down');
      
      $(this).closest(&quot;li&quot;).append($('.hiddendivcontent'));
          $(this).parent().children(&quot;.hiddendivcontent&quot;).toggle();
      }
      else if(target.hasClass(&quot;glyphicon-chevron-down&quot;)){
           $(e.target).toggleClass('glyphicon-chevron-right glyphicon-chevron-down');
           $(this).parent().children(&quot;.hiddendivcontent&quot;).toggle();
          
      }
      
  } );
  </code></pre>
  <p>When i click on the list items <em>Menu1</em>, it should again append the <code>&lt;ul class=&quot;hiddendivcontent&quot;&gt;..&lt;/ul&gt;</code> as a child inside the <em>Menu1</em>. So finally my output should be like</p>
  <pre><code>Project1
     Menu1
       Menu1
       Menu2
     Menu2
  Project2
  </code></pre>
  <p>The problem is , when i click on the Menu1, I am getting an exception:</p>
  <pre><code>Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': The new child element contains the parent. 
  </code></pre>
  <p>The problem is with the append(). But I dont know how to solve it.I am new to Jquery and Javascript. Can anyone please suggest me some ideas.</p>
  <p>Thanks in advance.</p>