1//insert new Element after some reference Element
2function insertAfter(newElement, referenceElement) {
3 referenceElement.parentNode.insertBefore(newElement, referenceElement.nextSibling);
4}
5
6//example usage
7var newElement = document.createElement("div");
8 newElement.innerHTML = "my New Div Text";
9var myCurrentElement= document.getElementById("myElementID");
10 insertAfter(newElement, myCurrentElement);