Welcome to WebmasterWorld Guest from 54.146.233.30

Forum Moderators: incrediBILL

Message Too Old, No Replies

Adding multiple nodes in one go

     

neil laurance

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

Inactive Member
Account Expired

 
 


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?

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

Preferred Member

10+ Year Member

joined:Oct 26, 2000
posts:414
votes: 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 July 30, 2001 (gmt 0)

Inactive Member
Account Expired

 
 


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

Neil

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members