Can I access to iframe 's parent's element from the iframe page

后端 未结 1 1498
广开言路
广开言路 2021-01-07 01:39

First the two page in under the same domain

In the parent page.htm I have only a element like input#test,

then I set a iframe in the parent page

1条回答
  •  一向
    一向 (楼主)
    2021-01-07 02:03

    Try

    var input = $(window.self.top).contents().find('input#test');
    

    or

    var input = $(window.self.top.document).find('input#test');
    

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