$.fn.compare(element) -> Number
{HTMLElement|jQuery}
an element or jQuery collection to compare against.
{Number}
A bitmap number representing how the elements are positioned from each other.
If the code looks like:
$('#foo').compare($('#bar')) //-> Number
Number is a bitmap with with the following values:
| Bits | Number | Meaning |
|---|---|---|
| 000000 | 0 | Elements are identical. |
| 000001 | 1 | The nodes are in different documents (or one is outside of a document). |
| 000010 | 2 | #bar precedes #foo. |
| 000100 | 4 | #foo precedes #bar. |
| 001000 | 8 | #bar contains #foo. |
| 010000 | 16 | #foo contains #bar. |
Compares the position of two nodes and returns a bitmask detailing how they are positioned relative to each other.
You can expect it to return the same results as compareDocumentPosition. Parts of this documentation and source come from John Resig.
Demo