[Javascript] looping through nodeList
Roland Dong
rdong at advance.net
Tue Oct 18 13:51:56 CDT 2005
for(var i=0; i<anchors.length; i++){
Var item=anchors[i];
alert(item);
}
> -----Original Message-----
> From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
> On Behalf Of Anthony Ettinger
> Sent: Tuesday, October 18, 2005 2:39 PM
> To: javascript at LaTech.edu
> Subject: [Javascript] looping through nodeList
>
> Can't seem to get this down, I get an HTML object, but
> it's length is zero.
>
> var anchors = document.getElementsByTagName("a");
> alert(anchors); // yields [object HTML Collection]
>
> for (anchor in anchors)
> {
> var item = anchor;
> alert(item); //yields length, item, namedItem
> (once)
> }
>
> at this point, I cannot figure out for the life of me
> how to access an instance of the anchors list.
> Basically, I just want to call getAttribute("href") on
> it.
>
> It seems as though anchors is not really a nodeList,
> more like a list of metadata about the nodeList.
>
> Thanks.
>
> Anthony Ettinger
> ph: (408) 656-2473
> web: http://www.apwebdesign.com
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list