The text node can only exist within one div, it's not a quantum
particle happily living in superposition across all five.
I love it, what a brilliant way to put it.
On Dec 12, 12:08 pm, T.J. Crowder t...@crowdersoftware.com wrote:
Hi Cyrus,
The text node can only exist within one div, it's not a quantum
particle happily living in superposition across all five. :-) It's
getting appended five times, but each time the previous parent loses
it: appendChild: Adds the node newChild to the end of the list of
children of this node. If the newChild is already in the tree, it is
first removed.[1]
[1]http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-184E7107
HTH,
--
T.J. Crowder
tj / crowder software / com
On Dec 12, 3:00 pm, Cyrus arianglan...@googlemail.com wrote:
Hi there,
I have a weird problem. Imagine following html code:
div class=test/div
div class=test/div
div class=test/div
div class=test/div
div class=test/div
I want to insert other html-code inside all divs class=test:
var html = document.createTextNode('test');
$$('.test').each(function(element) {
element.appendChild(html);
console.log(element);
});
This javascript code is executed after the dom:loaded event is fired.
The each function is executed 5 times, only html is appended only once
(at the last div). If I exchange the line:
element.appendChild(html);
into:
element.appendChild(document.createTextNode('test'));
every div contains the text 'test' - Does anyone knows why it only
works once with a variable?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Prototype script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---