Created
February 4, 2016 20:05
-
-
Save ghostwriter/cf2000de78174b2e1827 to your computer and use it in GitHub Desktop.
Quick 'n Dirty DOM insertion Function when there is no JS library
This file contains 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
// More elaborate code can be found here: | |
// https://github.com/jquery/jquery/blob/master/src/manipulation.js | |
function prepend(target, elem) { | |
target.insertBefore(elem, target.firstChild); | |
} | |
function append(target, elem) { | |
target.appendChild(elem); | |
} | |
function before(target, elem) { | |
target.parentNode.insertBefore(elem, target); | |
} | |
function after(target, elem) { | |
target.parentNode.insertBefore(elem, target.nextSibling); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment