View Full Version : swapNode equivalent in firefox

06-17-2011, 05:34 PM
Do we have any equivalent of swapNode method in firefox?

06-17-2011, 08:49 PM
// You can write your own function and pass both nodes as arguments.

function swap(a, b){
var pa1= a.parentNode, pa2= b.parentNode, sib= b.nextSibling;
if(sib=== a) sib= sib.nextSibling;
pa1.replaceChild(b, a);
if(sib) pa2.insertBefore(a, sib);
else pa2.appendChild(a);
return true;