smokinggun source code
back to Code | back to Home
Swaps two DOM objects.

Info | Source
sg_swapNode source
	
	view source for the JS code
	
	
Info Swaps object0 with object1.

This was meant as a solution to IE for Windows proprietary swapNode method.

Note: Events are not cloned. You will need to add event cloning to this, if required.
Could use better error detection.

Syntax
sg_swapNode(object0,object1);
nObject0 = sg_swapNode(object0,object1); //will return the cloned object0
Example
objA = document.getElementById("obj0");
objB = document.getElementById("obj1");
sg_swapNode(objA,objB);
/* or */
t = sg_swapNode(objA,objB);

swap 0 & 1 | swap 0 & 2

0
1
2
3