我發現了一些奇怪的東西,也許有工作?jQuery:通過數據屬性從iframe中獲取父文檔中的元素
我有一個選擇:[data-pcId=1369592034]
// alerts 1, it finds the carousel in the parent document which
//has the attribute: data-pcId="1369592034"
alert($('.carousel', window.parent.document).length);
// alerts 0, so not found
alert($(selector, window.parent.document).length);
當我在Firebug型$(selector, window.parent.document)
或$(selector)
它確實找到元素,當然這兩個查詢實際上是在做同樣的,因爲它會檢查以外的元素iframe
然後window.parent.document
與document
相同
而問題是? – adeneo
[**適合我**](http://jsfiddle.net/doktormolle/JFFtN/) –