sundemon
Programmer
- Aug 11, 2001
- 125
Hi,
Is there a way to dynamically access the array of elementsById from a page/document?
Here is an example:
<html>
<head>
<script language='javascript'>
function showListofIDs(){
//?????? show/alert() array or list of div IDs?
}
</script>
</head>
<body onload="showListofIDs();">
<div id="firstDiv"></div>
<div id="secondDiv"></div>
<div id="thirdDiv"></div>
</body>
</html>
What I'd like to do is be able to access or loop through all elements (i.e. ["firstDiv","secondDiv","thirdDiv"])on a given page (to say, change visibilty or position, etc.) without having to create an array of div IDs in advance, or have to manually update that array if I add or subtract elements to the page.
Any suggestions for code or tutorials on the subject?
Thanks,
sundemon
Is there a way to dynamically access the array of elementsById from a page/document?
Here is an example:
<html>
<head>
<script language='javascript'>
function showListofIDs(){
//?????? show/alert() array or list of div IDs?
}
</script>
</head>
<body onload="showListofIDs();">
<div id="firstDiv"></div>
<div id="secondDiv"></div>
<div id="thirdDiv"></div>
</body>
</html>
What I'd like to do is be able to access or loop through all elements (i.e. ["firstDiv","secondDiv","thirdDiv"])on a given page (to say, change visibilty or position, etc.) without having to create an array of div IDs in advance, or have to manually update that array if I add or subtract elements to the page.
Any suggestions for code or tutorials on the subject?
Thanks,
sundemon