iframe获取父窗口中的父窗口中的另外一个iframe中的元素问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Lemostic/article/details/81194974
  1. 页面层次结构如下:
    ————- mainPage(mainPage有两个iframe:iframe1和iframe2)
    ————————iframe1
    ————————iframe2(iframe2中又嵌套一个iframe:iframe2_1)
    ———————————–iframe2_1

现在,要在iframe2_1中操作mainPage页面中的iframe1下面的某个元素,可以按照如下方式操作:

var selector = $(top.parent.iframe1).contents().find("#selectorId");

亲测可用,不知道大家有没有遇到过同样的问题。

猜你喜欢

转载自blog.csdn.net/Lemostic/article/details/81194974