我想实现compareDocumentPosition.Resig 在这方面做了一个很好的开端.我已经把他的代码整理好了
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.sourceIndex) {
ret += 2;
}
} else {
ret += 1;
}
}
return ret;
}
Run Code Online (Sandbox Code Playgroud)
这适用于Element但不适用于 …
我有一个id为给<tr id="tagTR">
定上述,是否有可能找到下一个input:text元素,无论其间是否有任何其他标记.是否有一个jQuery选择器,我可以用于这种情况?
例如 :
<tr id="tagTR">
</tr>
<tr id="tagRed">
<td> </td>
</tr>
<div>
<tr>
<td>
<input> // This is what I want to get to.
</td>
</tr>
</div>
Run Code Online (Sandbox Code Playgroud)