In IE6 that seems to be the case, but I discovered that by accident with a buggy script. Haven't deliberately tested what happens in other browsers, I would think that they probably all just return the first element they find with the correct ID but as the behaviour is describes as undefined I wouldn't write any scripts that depend on that.
On Jun 13, 1:31 am, "Aaron Heimlich" <[EMAIL PROTECTED]> wrote: > On 6/12/07, Dan G. Switzer, II <[EMAIL PROTECTED]> wrote: > > > > > Plus, what happens if you have: > > > <div id="bam" /> > > > <span id="bam" /> > > > What if you need to retrieve the span tag? If it's checking #bam first, > > won't it only find the <div /> element? > > The DOM2 has this to say: > > getElementById introduced in DOM Level 2 > > > Returns the Element whose ID is given by elementId. If no such element > > exists, returns null. Behavior is not defined if more than one element has > > this ID. > > Source:http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-getElBId > > I would think that the first one the browser finds is selected, but I can't > be certain of that as I've never actually tried to do this. > > -- > Aaron Heimlich > Web Developer > [EMAIL PROTECTED]://aheimlich.freepgs.com