Home >Web Front-end >JS Tutorial >jQuery gets the IFrame and its parent window object and uses
This time I will bring you jQuery to obtain and use IFrame and its parent window object. What are the precautions for jQuery to obtain and use IFrame and its parent window object. 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
Get the elements in the iframe in the parent window
格式:$("#iframe的ID").contents().find("#iframe中的 控件 ID").click(); 实例:$("#ifm").contents().find("#btnOk").click();
Get the elements in 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, and more How exciting, please pay attention to other related articles on php Chinese website!
Recommended reading:
How jquery makes iframe adaptive to the front-end height
jQuery cross-domain operation DOM method in iframe
JSONP solves ajax cross-domain problem (with code)
The above is the detailed content of jQuery gets the IFrame and its parent window object and uses. For more information, please follow other related articles on the PHP Chinese website!