swapping dom elements

Joined: 11/28/2008

This may seem like a silly thing to ask, but I'm not that great at javascript and I can't find anywhere on how to simply swap two html elements (<tr>s in this case). I couldn't find anything in the YUI lib on doing it nor any help on the internet. Thought someone around here might be able to help.

Thanks!
Joey

My blog about web development.
And my site about game development.

>>> math.sqrt(-1) == joey101
True

Joined: 11/28/2008
You'll want to get the index

You'll want to get the index of both rows. From there, you can probably accomplish it by storing the innerHTML from both rows and replacing them with each other.

I don't know what you're trying to accomplish, so you'll probably need more code to handle the child nodes of each <tr>

Who can bring a charge to God's elect? It is God who justifies!

Joined: 11/28/2008
Since you mentioned you

Since you mentioned you sifted through YUI, there is something called swapNode ala: YAHOO.util.DDM.swapNode(nodeA, nodeB);

That's in the Drag and Drop file... although I would think it would be in DOM... unfortunately it's not.

Joined: 11/28/2008
Thanks polvero, that looks

Thanks polvero, that looks like what I'm wanting. /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

My blog about web development.
And my site about game development.

>>> math.sqrt(-1) == joey101
True