function insertAfter(newElement,targetElment) {
var parent = targetElment.parentNode;
if(parent.lastChild == targetElment) {
parent.appendChild(newElement);
} else {
parent.insertBefore(newElement,targetElment.nextSibling);
}
}
Because the DOM Node does not have this method, if you want to use it this way, just implant the method into the Node prototype
This way you can use some processing of
parent.insertAfter(newElement, targetElment)
,这里模仿了insertBefore
.