473,406 Members | 2,387 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,406 software developers and data experts.

Push a DOM element down one level?

I want to take a document that contains a number of tables and wrap the
tables inside new elements. I have tried something similar to the
following:

tparent = table.parentNode;
wrapper = document.createElement('DIV');
wrapper.appendChild(table);
tparent.replaceChild(wrapper,table);

This doesn't seem to work though (tested in Safari).

--
Kevin Smith
Ke*********@sas.com
Jul 20 '05 #1
1 1587
Kevin Smith <Ke*********@sas.com> writes:
I want to take a document that contains a number of tables and wrap the
tables inside new elements. I have tried something similar to the
following:

tparent = table.parentNode;
wrapper = document.createElement('DIV');
wrapper.appendChild(table);
A DOM node can only have one parent. At this point, you *move* the
table into the wrapper ...
tparent.replaceChild(wrapper,table);


.... so it is no longer a child of tparent.

Try switching the operations:

tparent = table.parentNode;
wrapper = document.createElement('DIV');
tparent.replaceChild(wrapper,table);
wrapper.appendChild(table);

/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

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

Similar topics

0
by: Ingrid | last post by:
Am I right in thinking that datatyping at element level ie <xs:element name="num" type="xs:integer"> and specifying a choice of attribute values ie <xs:attribute name="kind"> <xs:simpleType>...
7
by: ???????J | last post by:
Javascript may inquire the push down menu value, can I inquire the description? The following example, the variable($answer) can be get the menu1's value. For example, if I select first data,...
3
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following...
3
by: Andrew Phillipo | last post by:
In IE5 I am working with a lot of code that uses Array.push() as well as for(var i in myArray) {} Great - so I'm fixing the Array.prototype.push function for browsers without it. That...
1
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections...
7
by: giangiammy | last post by:
hi all, I need to implement a web page with a table: the page structure i fixed, the tables field are updating from time to time. The table could be quite big, but just some fields change...
4
by: Ben Kim | last post by:
Hello all, We are re-developing a software product that requires push technology (wireless and hardwired). Microsoft used to support this technology in IE but dropped it for whatever reason. ...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
4
by: kj7ny | last post by:
I have been able to get xml.dom.minidom.parse('somefile.xml') and then dom.getElementsByTagName('LLobjectID') to work to the point where I get something like: which I can get down to <DOM...
5
by: SuneR | last post by:
Hi, I am having problems figuring out how to make Firefox behave, and output the HTML I want it to output. The thing I want done is actually quite simple. I have a <labeltag, and inside it, I...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.