Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    28
    Thanks
    2
    Thanked 0 Times in 0 Posts

    swapNode equivalent in firefox

    Do we have any equivalent of swapNode method in firefox?

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    727
    Thanks
    35
    Thanked 132 Times in 123 Posts
    // You can write your own function and pass both nodes as arguments.


    Code:
    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;
    }
    Last edited by mrhoo; 06-17-2011 at 07:52 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •