JQuery operation iframe parent page and child page elements and methods of of instance

  • 2020-03-29 23:54:29
  • OfStack

The following is a simple use of Jquery to manipulate some of the iframe records, which can be implemented using pure JS and.

First, how to find a parent page element in an iframe:
$(' # id 'window. The parent. The document)

Second, get the element method in the iframe in the parent page:
$(this). The contents (.), find (" # suggestBox ")

Third, invoke the methods and variables defined in the parent page in the iframe:
The parent. The method
The parent. The value

Iframe USES jquery to get the body of the parent page

The iframe. HTML

<script src='jquerymin.js'>
<body id='1'>
    <div>it is a iframe</div>

        var c = $(window.parent.document.body) //The method of trouble: var c = $($(window). Eq. (0) [0] parent. The document), find (" body "); I forgot to use the previous method



Related articles: