//DOM does not provide insertAfter() method
function insertAfter( newElement, targetElement){
var parent = targetElement.parentNode;
if (parent.lastChild == targetElement) {
// If the last node is the target element, add it directly. Because the default is the last
parent.appendChild(newElement);
}
else {
parent.insertBefore(newElement, targetElement.nextSibling);
//If not, insert in the target element in front of the next sibling node. That is, behind the target element
}
}
jQuery document operation - insertAfter() method