compareDocumentPosition method
Compares the position of two nodes in a document.
![]() ![]() |
Syntax
object.compareDocumentPosition(otherNode)Parameters
- otherNode [in]
-
Type: IHTMLDOMNode
The node to be compared to the reference node, which is the node executing the method.
Return value
Type: Number
Describes how the position of the node specified by the otherNode parameter relates to the position of the reference node. The return value contains one or more of the following flag values:
| Return value | Description |
|---|---|
|
The nodes are disconnected. |
|
The position of the node specified by the otherNode parameter precedes the position of the reference node. |
|
The position of the node specified by the otherNode parameter follows the position of the reference node. |
|
The reference node contains the node specified by the otherNode parameter. |
|
The node specified by the otherNode parameter contains the reference node. |
|
The node positions depend on the DOM implementation and cannot be compared. |
Standards information
Remarks
For information about the factors that affect the position of nodes within the DOM, see the Document Object Model (DOM) Level 3 Core Specification from the World Wide Web Consortium (W3C).
Windows Internet Explorer 9. The compareDocumentPosition method is supported only when webpages are displayed in IE9 Standards mode.
See also
- a
- applet
- attribute
- audio
- button
- div
- document
- documentType
- frame
- iframe
- img
- input type=button
- input type=checkbox
- input type=email
- input type=file
- input type=hidden
- input type=image
- input type=number
- input type=password
- input type=radio
- input type=range
- input type=reset
- input type=search
- input type=submit
- input type=tel
- input type=text
- input type=url
- label
- legend
- marquee
- media
- object
- optGroup
- option
- ProcessingInstruction
- select
- source
- span
- table
- textArea
- TextNode
- video

