Getting the contents of iframe

后端 未结 1 1107
夕颜
夕颜 2021-01-26 03:01

I\'m currently trying to find the element located in an iframe. The hierarchy goes like this.

html > body > form#form1 > iframe#report-container > html > body > form#f

1条回答
  •  不要未来只要你来
    2021-01-26 03:48

    You don't need jQuery to do this necessarily.

    var iFrame = document.getElementById('iFrameId').contentDocument;
    var desiredElement = iFrame.getElementById('pageBreaker');
    

    Using the document API we can easily get the iFrame element and pull the content document out of it. Then it is trivial locating an element via its ID.

    0 讨论(0)
提交回复
热议问题