Home >Web Front-end >JS Tutorial >JQuery cross-Iframe selection implementation code_jquery

JQuery cross-Iframe selection implementation code_jquery

WBOY
WBOYOriginal
2016-05-16 18:21:10999browse

Select elements in the iframe from the parent page:

Copy code The code is as follows:

$( '#btnCancel',$('#PopFrame')[0].contentWindow.document)


Select elements in the parent page from the iframe page:
Copy code The code is as follows:

$("#PopContainer",parent.document)

The following is the solution from other netizens:
It had to be implemented by combining the DOM method and the jquery method

1. Select all the radio buttons in the IFRAME in the parent window
$(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");

2. In IFRAME Select all radio buttons in the parent window
$(window.parent.document).find("input[@type='radio']").attr("checked","true");

iframe: