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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---