如何使用 jQuery 测试元素是否驻留在 iFrame 中,如果存在,如何选择该 iFrame?
这将做到。
var elementDocument = $("#your-element").prop("ownerDocument");
var iframeOwner = $("iframe").filter(function() {
return this.contentDocument == elementDocument;
});
Run Code Online (Sandbox Code Playgroud)
它应该比公认的答案更快。
| 归档时间: |
|
| 查看次数: |
2284 次 |
| 最近记录: |