Created
October 1, 2016 19:48
-
-
Save englishextra/75020c8ba3b389b19d501d8ec88e3121 to your computer and use it in GitHub Desktop.
Adds Element as fragment AFTER NeighborElement
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
/*! | |
* Adds Element as fragment AFTER NeighborElement | |
* gist.github.com/englishextra/75020c8ba3b389b19d501d8ec88e3121 | |
* @param {String|object} e HTML Element to append after | |
* @param {Object} a target HTML Element | |
* appendFragmentAfter(e,a) | |
*/ | |
var appendFragmentAfter=function(e,a){"string"===typeof e&&(e=document.createTextNode(e));var p=a.parentNode||"",s=a.nextSibling||"",df=document.createDocumentFragment();p&&s&&df.appendChild(e)&&p.insertBefore(df,s);return!1;}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment