Return to Snippet

Revision: 49549
at July 25, 2011 01:35 by alberomo


Initial Code
function insertAfter(newElement,targetElement) {
   var parent = targetElement.parentNode;
   if (parent.lastChild == targetElement) {
      parent.appendChild(newElement);
   } else {
      parent.insertBefore(newElement,targetElement.nextSibling);
   }
}

Initial URL


Initial Description
Description: A function to insert a new element after an existed one.
Arguments: The new element and the target element the
new element should be inserted after.

Initial Title
insertAfter Function

Initial Tags


Initial Language
JavaScript