File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Regarding DOM methods Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Regarding DOM methods" Watch "Regarding DOM methods" New topic
Author

Regarding DOM methods

Vivek Alampally
Ranch Hand

Joined: Jul 10, 2008
Posts: 65
Hi Can anyone here please explain me what does the following code do with an example?

while(node.firstChild)
node.removeChild(node.firstChild)

assume node is sth like var node=document.getElementById(id);

I know that it removes all the child nodes of a node represented by id="id". I dont know how a while loop works here.

Thanks
Vivek
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 14857


It loops until there are no more children left.

Eric
 
 
subject: Regarding DOM methods
 
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture