homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

Adding multiple nodes in one go
neil laurance

 1:06 pm on Jul 30, 2001 (gmt 0)

Is there a simple way of adding nodes in one go using DOM? For example I have the following code:

function addMyNode() {
node = document.getElementById("#001");
element = document.createElement('li');
text = document.createTextNode('Child 2');
element.appendChild(text, null);
node.appendChild(element, null);

Called with:
<ul id="#001">
<li>Child 1</li>
<input type="button" value="Insert new Node" onClick="addMyNode()"></input>

I wanted to use a DocumentFragment to append several children in one go, but the method createDocumentFragment just returns an empty one, as opposed to parsing the contents of a parameter. Anyone have any ideas?



 2:51 pm on Jul 30, 2001 (gmt 0)

Hi Neil
The only idea I have using the function addMyNode would be to load an array and put it in a loop.
I am sure you already know but the js you are using will only work in ie 5.x and nn 6.

neil laurance

 3:26 pm on Jul 30, 2001 (gmt 0)

Yep, thats the advantage of making an intranet oriented product. We get to choose what browsers we will code for ;)


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved