如何在firefox中使用JQuery访问parent.document元素?

Ke.*_*Ke. 31 firefox jquery

例如:

$(elementid,top.document).attr(attributeName)
Run Code Online (Sandbox Code Playgroud)

要么

$(elementid,parent.document).attr(attributeName)
Run Code Online (Sandbox Code Playgroud)

适用于IE或Chrome,但在Firefox中不起作用.

有谁知道firefox等价是什么?

谢谢!

DLS*_*DLS 73

关于什么:

window.parent.$(elementid).attr(attributeName);
Run Code Online (Sandbox Code Playgroud)

  • 父节点不支持jquery时不工作. (3认同)
  • window.parent.getElementById(elementid)[attributeName]表示没有jQuery (3认同)

小智 16

试试这个:

$("#myid", top.document); 
Run Code Online (Sandbox Code Playgroud)

要么

$("#myid", parent.document.body); 
Run Code Online (Sandbox Code Playgroud)

参考