Created
November 3, 2011 12:13
-
-
Save carlcarl/1336347 to your computer and use it in GitHub Desktop.
prependChild and insertAfter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prependChild(o,s) | |
{ | |
if(s.hasChildNodes()) | |
{ | |
s.insertBefore(o,s.firstChild); | |
} | |
else | |
{ | |
s.appendChild(o); | |
} | |
} | |
function insertAfert(o,s) | |
{ | |
if(s.nextSibling!=null) | |
{ | |
s.parentNode.insertBefore(o,s.nextSibling); | |
} | |
else | |
{ | |
s.parentNode.appendChild(o); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment