Created
September 2, 2015 08:29
-
-
Save vlakoff/f770899d03953a7fc07e to your computer and use it in GitHub Desktop.
Functions for quick'n'dirty DOM insertion 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
// for more elaborate code, see for instance: | |
// 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