DocumentPosition

A bitmask indicating the relative document position of a node with respect to another node. Returned by Node.compareDocumentPosition.

Values

ValueMeaning
none0

Set when the two nodes are in fact the same

disconnected1

Set when the two nodes are not in the same tree

preceding2

Set when the second node precedes the first

following4

Set when the second node follows the first

contains8

Set when the second node _contains the first

containedBy16

Set when the second node is contained by the first

implementationSpecific32

Set when the returned ordering of the two nodes may be different across DOM implementations; for example, for two attributes of the same node, an implementation may return preceding | implementationSpecific and another may return following | implementationSpecific, because at the DOM level the attributes ordering is unspecified

Meta