Home >Web Front-end >JS Tutorial >Detailed explanation of the iframe case of jQuery getting the parent window and child window

Detailed explanation of the iframe case of jQuery getting the parent window and child window

php中世界最好的语言
php中世界最好的语言Original
2018-04-26 15:37:111447browse

This time I will bring you a detailed explanation of the jQuery case of obtaining the iframe of the parent window and the child window. What are the precautions for jQuery to obtain the iframe of the parent window and the child window. The following is a practical case. Let's take a look. .

In web development, iframes are often used. It is inevitable that you need to use elements in the iframe in the parent window, or use elements of the parent window in the iframeframe

jquery

Get the elements in the iframe in the parent window

1,

格式:$("#iframe的ID").contents().find("#iframe中的控件ID").click();//jquery 方法1
实例:$("#ifm").contents().find("#btnOk").click();//jquery 方法1

2,

格式:$("#iframe中的控件ID",document.frames("frame的name").document).click();//jquery 方法2
实例:$("#btnOk",document.frames("ifm").document).click();//jquery 方法2

Get the elements of the parent window in the iframe

格式:$('#父窗口中的元素ID', parent.document).click();
实例:$('#btnOk', parent.document).click();

I believe you have mastered the method after reading the case in this article. For more exciting content, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Jquery gets the Dom element in the iframe page (with code)

jquery js calls the iframe parent window Detailed explanation of steps with sub-window

The above is the detailed content of Detailed explanation of the iframe case of jQuery getting the parent window and child window. For more information, please follow other related articles on the PHP Chinese website!

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