title: Javascript insert row into table after row with certain id
body: <p>I have a table where each row has its unique id. Say there are rows with id='id25' and id='id26'. I need to insert a new row after row with id='id25'. I am using Vanilla JS without jQuery.</p>
  
  <p>I have tried this:</p>
  
  <pre><code>var refElement = document.getElementById('id'+id);
  var newrow = document.createElement("tr");
  if (refElement) {
      refElement.insertBefore(newrow, refElement.nextSibling);
  }
  </code></pre>
  
  <p>but it throws me an error saying 
  <code>Failed to execute 'insertBefore' on 'Node'</code></p>
  
  <p>The node before which the new node is to be inserted is not a child of this node.</p>
  
  <p>I know how to insert rows into top or bottom of the table but now I have an id as a reference to a particular row.</p>
  
  <p>Any suggestions would be welcome</p>