jquery 父頁面 子頁面 同級頁面 調用

來源:互聯網
上載者:User

標籤:

項目中用到  代碼 ,先 展示 ,以便以後用到,直接看下就會明白。

var li_divs = parent.$("#servicelist")[0].contentWindow.$("#ccList .li.div");
li_divs.each(function(){
if($(this).find("a").eq(0).attr("attrid")==$("#id").val()){
$(this).find("a").eq(0).text($("#name").val());
}
});

 

 

以下內容來自轉載

主要知識點

1:document.getElementById("ii").contentWindow 得到iframe對象後,就可以通過contentWindow得到iframe包含頁面的window對象,然後就可以正常訪問頁面元素了;

2:$("#ii")[0].contentWindow  如果用jquery選取器獲得iframe,需要加一個【0】;

3:$("#ii")[0].contentWindow.$("#dd").val() 可以在得到iframe的window對象後接著使用jquery選取器進行頁面操作;

4:$("#ii")[0].contentWindow.hellobaby="dsafdsafsdafsdafsdafsdafsadfsadfsdafsadfdsaffdsaaaaaaaaaaaaa"; 可以通過這種方式向iframe頁面傳遞參數,在iframe頁面window.hellobaby就可以擷取到值,hellobaby是自訂的變數;

5:在iframe頁面通過parent可以獲得首頁面的window,接著就可以正常訪問父親頁面的元素了;

6:parent.$("#ii")[0].contentWindow.ff; 同級iframe頁面之間調用,需要先得到父親的window,然後調用同級的iframe得到window進行操作;

jquery 父頁面 子頁面 同級頁面 調用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.