SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: DOM move a node
-
Jun 7, 2007, 14:21 #1
- Join Date
- Aug 2004
- Location
- Colwyn Bay, Wales, UK
- Posts
- 287
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
DOM move a node
Hi there, been searching google for about an hour but found nothing really usefull.
I want to move a node from its current position, wherever in the parent it may be, to the top of its parent node.
so say i have:
a very abbridged dictionary
- abacus
- banana
- candle
i might want to move "banana" to be above "abacus". I've seen plenty of things about deleting and removing nodes, but to clone and remove would seem a bit of a cludge. Is there anyone who acn help?
-
Jun 7, 2007, 14:37 #2
- Join Date
- Aug 2005
- Posts
- 453
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Did you read this article :
http://www.webreference.com/programm.../chap17/8.htmlComputers and Fire ...
In the hands of the inexperienced or uneducated,
the results can be disastrous.
While the professional can tame, master even conquer.
-
Jun 7, 2007, 14:44 #3
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
You can just move it by using insertBefore on an existing node and inserting it elsewhere.
-
Jun 7, 2007, 15:03 #4
- Join Date
- Apr 2006
- Posts
- 802
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:window.promote=function(node){ if(node.previousSibling){ pa= node.parentNode; pa.insertBefore(node,pa.firstChild); } return node; }
Bookmarks