jquery/js 获取iframe父窗口、子窗口元素

jquery

获取子窗口


document.getElementById("iframe的id").contentWindow.document.getElementById("iframe中的元素id");  	
 
var ifmEle = document.getElementById("ifrId").contentWindow.document.getElementById("child"); 

获取父窗口


window.parent.document.getElementById('parent')

js

获取子窗口

// $("#ifrId").contents();获取iframe的jquery文档级元素,相当于$(document)

$("#ifrId").contents().find("#child")

获取父窗口


$('#parent', parent.document).html()

猜你喜欢

转载自blog.csdn.net/qq_42068550/article/details/117369468