compareDocumentPosition: other(3)
Compares the relative position of the node on which
the method is invoked with the position of the other
node. The return value is a bit
mask that indicates the relative position between the two nodes in
document order. The following table lists the bit mask members and
their meanings:
Constant name | Value | Meaning |
---|---|---|
DOCUMENT_POSITION_DISCONNECTED | 0x01 | The two nodes are disconnected (do not share a common container ancestor) and cannot be compared. |
DOCUMENT_POSITION_PRECEDING | 0x02 | The |
DOCUMENT_POSITION_FOLLOWING | 0x04 | The |
DOCUMENT_POSITION_CONTAINS | 0x08 | The |
DOCUMENT_POSITION_CONTAINED_BY | 0x010 | The |
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | 0x020 | The relative positions are implementation-specific, such as in the case of disconnected nodes. |
Raised if the two nodes are from incompatible DOM implementations and their relative positions cannot be determined.
public static final short DOCUMENT_POSITION_DISCONNECTED = 0x01; public static final short DOCUMENT_POSITION_PRECEDING = 0x02; public static final short DOCUMENT_POSITION_FOLLOWING = 0x04; public static final short DOCUMENT_POSITION_CONTAINS = 0x08; public static final short DOCUMENT_POSITION_CONTAINED_BY = 0x10; public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; public short compareDocumentPosition(Node other) throws DOMException;