brett wrote:
[color=blue]
> Only the first <div> executes in the following code. I'd like the
> second to execute as well. This code is dynamically generated so I
> won't know exactly how many <div> tags will be needed. If they can all
> use the same ID/Name that shouldn't be a problem.
> <div id="sample" style="width:100%"><h3>John slowly faded into
> view</h3></div>
> This area will not fade out.<br>
> <div id="sample" style="width:100%"><h3>Another fade occurs
> here.</h3></div>[/color]
The id attribute value of an element should be unique in the HTML
document so what you have is not a good idea.
As for iterating over div elements, you can find elements by their tag
name as follows:
var divs;
if (document.getElementsByTagName &&
(divs = document.getElementsByTagName('div'))) {
for (var i = 0; i < divs.length; i++) {
// access divs[i] here
}
}
--
Martin Honnen
http://JavaScript.FAQTs.com/