Re: accessing html collections
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: accessing html collections

From: <mumrah@gmail.com>
Date: Wed Dec 07 2005 - 20:45:46 CET

So if i'm parsing through the DOM, and i have some parents and i access
it's children:

object.childNodes

I should access the children via [0] and not item(0) ?

example: document.getElementById('foo').childNodes[0] as opposed to
document.getElementById('foo').childNodes.item(0)

I had always used the [] to access array elements in JS until i
starting writing this program that has to parse through an xml dom. The
site that i read up on that topic used to item() method so, naturally,
i used it as well. But i'm happy to change back to using brackets. less
typing :)
Received on Sun Dec 11 14:33:14 2005