Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] looping through nodeList
- From: allard-schripsema at procergs.rs.gov.br (Allard Schripsema)
- Subject: [Javascript] looping through nodeList
- Date: Tue Oct 18 14:02:50 2005
Hi there,
i dont know about your loop, but this works:
var anchors = document.getElementsByTagName("a");
for (var anchor = 0; anchor<anchors.length;anchor++){
var item = anchors[anchor];
alert(item.href)
}
(an excess of vars, but its just an example ok:-)
Hope this helps,
Allard Schripsema
-----Original Message-----
From: javascript-bounces@xxxxxxxxxx
[mailto:javascript-bounces@xxxxxxxxxx]On Behalf Of Anthony Ettinger
Sent: Tuesday, October 18, 2005 4:39 PM
To: javascript@xxxxxxxxxx
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@xxxxxxxxxx
https://lists.LaTech.edu/mailman/listinfo/javascript
- References:
- [Javascript] looping through nodeList
- From: Anthony Ettinger
- [Javascript] looping through nodeList
- Prev by Date: [Javascript] looping through nodeList
- Next by Date: [Javascript] looping through nodeList
- Previous by thread: [Javascript] looping through nodeList
- Next by thread: [Javascript] looping through nodeList
- Index(es):