I highly recommend you take a look at jQuery . The task you want to do is simple in pure Javascript, but if you do an extra DOM workaround, jQuery is going to save you countless hours of frustration. Not only this, but it works in all browsers and has a very good “finished document”.
Your problem resolved with jQuery looks like this:
$(document).ready(function() { var children = $("#node").children(); });
It searches for any element with the identifier "node", and then returns its children. In this case, children is a jQuery collection that can be repeated using a for loop. Alternatively, you can iterate over them using the each () command.
Soviut
source share