2
A
回答
6
只要幀訪問不受同源策略限制:
function getElem(selector, $root, $collection) {
if (!$root) $root = $(document);
if (!$collection) $collection = $();
// Select all elements matching the selector under the root
$collection = $collection.add($root.find(selector));
// Loop through all frames
$root.find('iframe,frame').each(function() {
// Recursively call the function, setting "$root" to the frame's document
getElem(selector, $(this).contents(), $collection);
});
return $collection;
}
// Example:
var $allImageElements = getElem('img');
相關問題
- 1. 如何使用遞歸在嵌套列表中查找元素?
- 2. 如何在嵌套列表中查找給定的元素?
- 3. MongoDB查找嵌套元素
- 4. 在查詢中查找嵌套元素
- 5. 在嵌套列表中查找相同的第二個元素 - 遞歸函數
- 6. 查找嵌套列表中指定的字符串與遞歸
- 7. 查找具有指定嵌套子元素的所有元素
- 8. 嵌套/遞歸MySQL查詢
- 9. 查找嵌套元素值的PHP DomXPath
- 10. 遞歸地查找數組的最大元素
- 11. 查找和upserting嵌套數組元素
- 12. 查找嵌套數組元素
- 13. 的SQL Server 2005 - 。嵌套遞歸查詢:(
- 14. 使用Selenium 2查找嵌套的iFrame
- 15. 隱藏元素遞歸樹嵌套的兩倍以上
- 16. 元素'a'不能嵌套在元素'iframe'中
- 17. Groovy ::地圖查找遞歸
- 18. 查找iframe中元素的窗口
- 19. 嵌套字典的遞歸
- 20. MVC3遞歸嵌套的WebGrid
- 21. Groovy的嵌套(?遞歸)XML
- 22. 使用簡單的HTML查找嵌套鏈接DOM(遞歸)
- 23. Python獲得第二小元素嵌套列表遞歸
- 24. 創建具有遞歸函數嵌套元素
- 25. 查詢Firebase中的嵌套元素
- 26. 查找給定元素後的實例
- 27. 遞歸刪除嵌套數組尋找一個特定的值
- 28. Clojure - 使用遞歸來查找列表中的元素數量
- 29. Java:遞歸查找列表中的最小元素
- 30. 嵌套自定義元素