homepage Welcome to WebmasterWorld Guest from 23.22.173.58
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

10+ Year Member



 
Msg#: 910 posted 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:

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

Called with:
<ul id="#001">
<li>Child 1</li>
</ul>
<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?

 

David

10+ Year Member



 
Msg#: 910 posted 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

10+ Year Member



 
Msg#: 910 posted 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 ;)

Neil

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