cross browser compare document position
问题 DOM4 compareDocumentPosition I want to implement compareDocumentPosition. Resig has made a great start at doing just this. I've taken his code and neatened it up function compareDocumentPosition(other) { var ret = 0; if (this.contains) { if (this !== other && this.contains(other)) { ret += 16; } if (this !== other && other.contains(this)) { ret += 8; } if (this.sourceIndex >= 0 && other.sourceIndex >= 0) { if (this.sourceIndex < other.sourceIndex) { ret += 4; } if (this.sourceIndex > other