Skip to content

Instantly share code, notes, and snippets.

@carlcarl
Created November 3, 2011 12:13
Show Gist options
  • Save carlcarl/1336347 to your computer and use it in GitHub Desktop.
Save carlcarl/1336347 to your computer and use it in GitHub Desktop.
prependChild and insertAfter
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