Home>Article>Web Front-end> How to get iframe with jquery
Jquery method to obtain iframe: Add jquery selector outside the dom method, the code is [$(window.frames["iframeChild"].document),$(window.parent.document)].
The operating environment of this tutorial: windows7 system, jquery3.2.1 version. This method is suitable for all brands of computers.
How to get iframe with jquery:
In the following web page, some people will use iframe. It is very simple for dom to get the iframe in the page:
Operation iframe in the parent window:
window.frames["iframeChild"].document //假如iframe的id为iframeChild
Operation of the parent window in the child window:window.parent.document
Then, use the method if you want to use jquery , how do we use jquery to get iframe? Here's how to collect it.
Getting the object of the page is actually adding the jquery selector outside the dom method:
Operation iframe in the parent window:
$(window.frames["iframeChild"].document) //假如iframe的id为iframeChild
Operation of the parent window in the child window:$(window.parent.document)
You can continue to obtain the dom in the iframe.
There are two ways to get the DOM object in the iframe
$(window.frames["iframeChild"].document).find("#child")
$("#child",window.frames["iframeChild"].document)
1.In Operate in the parent window to select all radio buttons in the IFRAME
$(window.frames["iframeChild"].document).find("input[@type='radio']").attr("checked","true");
2. Operate in the IFRAME to select all radio buttons in the parent window
$(window.parent.document).find("input[@type='radio']").attr("checked","true");
Related free learning recommendations:javascript(Video)
The above is the detailed content of How to get iframe with jquery. For more information, please follow other related articles on the PHP Chinese website!