jquery方法

在父窗口中获取iframe中的元素

//方法1
$("#iframe的ID").contents().find("iframe中的元素");
//实例:
$("#ifr").contents().find("#someid");
//方法2
$("#iframe中的控件ID",document.frames("frame的name").document);
//实例
$("#someid",document.frames("ifr").document);

在iframe中获取父窗口的元素

//方法
$('#父窗口中的元素ID', parent.document); //实例 $('#someid', parent.document);

js方法

在父窗口中获取iframe中的元素

//方法
window.frames["iframe的name值"].document.getElementById("iframe中控件的ID");
//实例
window.frames["ifr"].document.getElementById("someid");

在iframe中获取父窗口的元素

//方法
window.parent.document.getElementById("父窗口的元素ID");
//实例
window.parent.document.getElementById("someid");

欢迎补充!

相关文章:

  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案