/ Published in: JavaScript
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.
Expand |
Embed | Plain Text
function insertAfter(newElement,targetElement) { var parent = targetElement.parentNode; if (parent.lastChild == targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement,targetElement.nextSibling); } }
You need to login to post a comment.
