Home >Web Front-end >JS Tutorial >jquery gets the dom object in the iframe (two methods)_jquery

jquery gets the dom object in the iframe (two methods)_jquery

WBOY
WBOYOriginal
2016-05-16 17:30:261266browse

Operate the iframe in the parent window: $(window.frames["iframeChild"].document) //If the id of the iframe is iframeChild

Operate the parent window in the child window: $(window.parent.document)

Next, you can continue to obtain the dom in the iframe.

There are two ways to get the DOM object in the iframe

1 $(window.frames["iframeChild"].document).find("#child")
2 $("#child",window.frames["iframeChild"].document)

1. Select all radio buttons in the IFRAME in the parent window

Copy code The code is as follows:

$(window.frames["iframeChild"].document).find("input[ @type='radio']").attr("checked","true");

2. Select all radio buttons in the parent window in IFRAME
Copy code The code is as follows:

$(window.parent.document).find("input[@type= 'radio']").attr("checked","true");
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn