IE Question: element.previousSibling returns phantom object
Posted on 2004-03-22
<span onclick='alert(this.previousSibling.tagName)'>click me</span>
When you click on "click me", the result should be a popup box that says, "INPUT". However, the result is "undefined".
If you change the reference from "this.previousSibling.tagName" to "this.previousSibling.previousSibling.tagName" it works. Seems like there's some phantom object between the "INPUT" tag and the "SPAN" tag. NOTE: I added some code to display the number of children below the "FORM" tag. The result was 2. Weird.
However, if I replace the "INPUT" tag with some non-form tag, I only need one "previousSibling" reference to get the object...which makes sense.
Does anybody know if this is a known bug or if there is some extra object that pads form tags that I don't know about? I'd like to know before I start widely using the "Sibling" references with form tags. BTW, the same phenomenon applies for "nextSibling".