Swap DOM nodes
To swap DOM nodes you can use this example:
var oldNodeAtPosition = document.getElementById(existingNode);
var newNodeAtPosition = document.getElementById(retrievedNode);
// swap DOM nodes
// API: replaceChild(child1,child2) -- replace node child2 by node child1
oldNodeAtPosition.parentNode.replaceChild(newNodeAtPosition.cloneNode(true), oldNodeAtPosition);
newNodeAtPosition.parentNode.replaceChild(oldNodeAtPosition.cloneNode(true), newNodeAtPosition);
Comments
Post a Comment