I have the following code:
<div id="container">
<div id="cat1"></div>
<div id="cat2"></div>
<div id="cat3"></div>
</div>
I can do a insertBefore but there is no insertAfter... what if I want to append another cat to the container? Do I really have to use a nextSibling? It fells very strange that there is an insertBefore and for an insertAfter one has to use a hack. Are there alternatives to
function insertAfter(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
insertAfter(document.getElementById("tres"), myscript);