473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DOM element move

gsb
I have created a div tag and appended it as a child to the document body.

Obj=document.createElement('DIV');
Obj=document.body.appendChild(Obj);

Is there a way to move the object w/o deleting it and creating a new one?

Maybe a remove and appendBefore or appendAfter?

gsb
Jul 20 '05 #1
4 25041
"gsb" <gs*@QWest.net> writes:
I have created a div tag and appended it as a child to the document body.

Obj=document.createElement('DIV');
Obj=document.body.appendChild(Obj);
No need to assign the return value of "appendChild" to Obj. It returns
the appended node, which is already the value of Obj.
Is there a way to move the object w/o deleting it and creating a new one?
Any new insertion will move it. A DOM node can only occour once in a
document, so inserting it a new place will remove it from its previous
location.
Maybe a remove and appendBefore or appendAfter?


No need to remove. Just insertBefore where you need it.
someToBeParentNode.insertBefore(Obj,someNewSibling );

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
DU
gsb wrote:
I have created a div tag and appended it as a child to the document body.

Obj=document.createElement('DIV');
Obj=document.body.appendChild(Obj);

Is there a way to move the object w/o deleting it and creating a new one?

Maybe a remove and appendBefore or appendAfter?

gsb

insertBefore:
http://www.w3.org/TR/2000/REC-DOM-Le...l#ID-952280727

removeChild:
http://www.w3.org/TR/2000/REC-DOM-Le...#ID-1734834066

DU

Jul 20 '05 #3
Create a new DIV where you want to move the current object then
use 'oldDiv = Object.replaceChild(newDiv, oldDiv)';

I hope this has been helpful.

--
************************************
MUSIC24SEVEN
Pioneers of the
'Digital Entertainment Industry'
http://music24seven.com
************************************
"gsb" <gs*@QWest.net> wrote in message
news:e8****************@news.uswest.net...
I have created a div tag and appended it as a child to the document body.

Obj=document.createElement('DIV');
Obj=document.body.appendChild(Obj);

Is there a way to move the object w/o deleting it and creating a new one?

Maybe a remove and appendBefore or appendAfter?

gsb

Jul 20 '05 #4
gsb
Thanks all.

gsb
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Noah Spitzer-Williams | last post by:
Hello guys, I'm itinerating through my array using pointers in this fashion: image is unsigned char image do { cout << "image byte is: " << *image << endl;
3
by: \(¯`·.¸FlacK¸.·´¯\) | last post by:
Hi! I want to move a node from file "film1" to "film2" that has tag "FilmatoPartita". I have write the codo below, but it don't do anything...I don't see the error... I have forgotten something?...
7
by: William Payne | last post by:
(This post is related to "recent files menu"-post below. If I should have kept this in that thread, I apologise.) Hello, I have a function that adds a std::string to a std::vector. New entries are...
11
by: Richard Thompson | last post by:
I've got a memory overwrite problem, and it looks as if a vector has been moved, even though I haven't inserted or deleted any elements in it. Is this possible? In other words, are there any...
6
by: Jakob Bieling | last post by:
Hi, I want to move an element from a std::list to the end of the same list. To get this done, I thought I'd just do something like: std::list <intlst; lst.push_back (0); lst.push_back (1);...
7
by: Dennis Jones | last post by:
Hi, Is there is a way to *move* elements from one container to another with a single STL function? That is, can I move an element (or range of elements) between containers without doing a copy...
3
by: Giampaolo Rodola' | last post by:
Hi, I wanted to know if does exist a safe way to, given a heap, move an arbitrary element to the first position of the heap. Something like: --- Giampaolo...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.