ELEMENT TRAVERSAL
Prior to version 9, Internet Explorer did not return text nodes for white space in between elements while all of the other browsers did. This led to differences in behavior when using properties such as childNodes
and firstChild
. In an effort to equalize the differences while still remaining true to the DOM specification, a new group of properties was defined in the Element Traversal (www.w3.org/TR/ElementTraversal/
).
The Element Traversal API adds five new properties to DOM elements:
childElementCount
—Returns the number of child elements (excludes text nodes and comments).firstElementChild
—Points to the first child that is an element. Element-only version offirstChild
.lastElementChild
—Points to the last child that is an element. Element-only version oflastChild
.previousElementSibling
—Points to the previous sibling that is an element. Element-only version ofpreviousSibling
.nextElementSibling
—Points to the next sibling that is an...