- From: L. David Baron <dbaron@fas.harvard.edu>
- Date: Thu, 14 Oct 1999 12:02:41 -0400 (EDT)
- To: jfink@ryos.com, www-dom@w3.org
On Wed, 13 Oct 1999 13:02:26 -0400 (EDT), "Jeff Fink" (jfink@ryos.com) wrote: > > I want to switch the order of the rows in the table body and there does not > seem to be a straightforward way to do this. I can write this code: The better way to do this is to use the interfaces in the DOM Level 1 Core, rather than Level 1 HTML. The Level 1 HTML is really just a few convenience things added to Level 1 Core. Switching the rows can be accomplished in JavaScript by: var pTBody = document.getElementById("tbl").tBodies[0]; pTBody.insertBefore(pTBody.childNodes.item(1),pTBody.childNodes.item(0)); The second line inserts the second child of the TBODY before the first child. This insertion removes the second child from the tree, since it can't be in the tree twice, and therefore switches the rows. -David L. David Baron Sophomore, Harvard (Physics) dbaron@fas.harvard.edu Links, SatPix, CSS, etc. <URL: http://www.fas.harvard.edu/~dbaron/ > WSP CSS AC <URL: http://www.webstandards.org/css/ >
Received on Thursday, 14 October 1999 12:03:04 UTC