Created
October 7, 2018 18:57
-
-
Save avisek/b0f0c7c267fa79b612679054164ee49e to your computer and use it in GitHub Desktop.
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
function swapDomNodes(a, b) { | |
var afterA = a.nextSibling; | |
if (afterA == b) { | |
swapDomNodes(b, a); | |
return; | |
} | |
var aParent = a.parentNode; | |
b.parentNode.replaceChild(a, b); | |
aParent.insertBefore(b, afterA); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment