title: How to use the parentNode property multiple times?
body: <p>I have a question. How can I use the parentNode property multiple times?</p>
  
  <p>I know that I can make something like this:</p>
  
  <pre><code>document.getElementById("mytag").parentNode.parentNode.remove();
  </code></pre>
  
  <p>Or something like this. My Problem is not that I can add more or less .parentNode to remove whatever I want to remove.</p>
  
  <p>My Problem is that I want to create a user friendly app in which the user can self declare how many parentNodes should be removed.</p>
  
  <p>At first I tried to add .parentNode by a loop. It doesn't work. At second I tried the same with the eval() function. Same result.</p>
  
  <p>Is there a person who have a good solution how I can make this? It was very useful if there is a opportunity on which you only have to say the number of parentNodes.</p>
  
  <p>Here a little example. What I will be done "automatically":</p>
  
  <pre><code>myFunction(..., ..., 3) {
      ...
      document.getElementById("mytag").parentNode.parentNode.parentNode.remove();
  }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>myFunction(..., ..., 2) {
      ...
      document.getElementById("mytag").parentNode.parentNode.remove();
  }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>myFunction(..., ..., 1) {
      ...
      document.getElementById("mytag").parentNode.remove();
  }
  </code></pre>
  
  <p>Thank you very much.</p>
  
  <p>I prefere a solution in pure JS. An additional jQuery solution would be also nice.</p>