Click to See Complete Forum and Search --> : DOM question


jinkas
09-26-2003, 03:09 PM
Hey guys, just a quick question...

To reference the anchors in an HTML document, I know that I use document.anchors

However, what do I do to reference the DIVs and the SPANs that I have in my page? Is there an array that is automatically created for those, also? Thanks a ton for your help!

-jinkas

Vladdy
09-26-2003, 03:14 PM
document.body.getElementsByTagName(tagName) will return the array of elements which have a specified tag.

jinkas
09-26-2003, 03:17 PM
Originally posted by Vladdy
document.body.getElementsByTagName(tagName) will return the array of elements which have a specified tag.

So I would use something like this?:

divArray = document.body.getElementsByTagName(div);

for (i=0;i<divArray.length;i++) {
divArray[i].style.visibility = "visible";
}

Vladdy
09-26-2003, 03:41 PM
tagName is a string, so the it should be .getElementsByTagName('div');

jinkas
09-26-2003, 03:50 PM
Right. Thanks a ton for your help!