This is the first paragraph. I deliberately left out all empty text nodes.
This is the second paragraph that starts with an underline. This
paragraph is element x and contains a
strong tag that is element y which is
directly followed by an em tag
This is the third paragraph. It's preceded by a comment.
This page tests walking the DOM tree through firstChild and friends.
Test firstChild. The correct answers are <U> and #text,
respectively.
alert(x.firstChild.nodeName)
alert(y.firstChild.nodeName)
Test lastChild. The correct answers are <EM>and <CODE>,
respectively.
alert(x.lastChild.nodeName)
alert(y.lastChild.nodeName)
Test nextSibling. The correct answers are #comment and <EM>,
respectively.
alert(x.nextSibling.nodeName)
alert(y.nextSibling.nodeName)
Test parentNode. The correct answers are <DIV>and <P>,
respectively.
alert(x.parentNode.nodeName)
alert(y.parentNode.nodeName)
Test previousSibling. The correct answers are <P>and #text,
respectively.
alert(x.previousSibling.nodeName)
alert(y.previousSibling.nodeName)
Correct: 51 and <p> twice
var test = x.sourceIndex;
alert(test);
alert(x.nodeName);
alert(document.getElementsByTagName('*')[test].nodeName);
Correct: 54 and <strong> twice
var test = y.sourceIndex;
alert(test);
alert(y.nodeName);
alert(document.getElementsByTagName('*')[test].nodeName);