JavaScript - insertAfter Method

 

Like the insertBefore method, this inserts a node after the specified one. This requires the prototype.js framework.

  1. Object.extend(Element.Methods, {
  2. insertAfter: function(parent,newNode,referenceNode) {
  3. return parent.insertBefore(newNode,referenceNode.nextSibling);
  4. }
  5. });
  6. Element.addMethods();

Call this method as:
  1. parentNode.insertAfter(newNode,referenceNode);