baejusik
baejusik

Reputation: 71

how to access the element inside iframe, from parent document?

function contents_nb(name, height) {
    1. document.getElementById('contents_iframe').height = height+'px';
    2. var $currentIFrame = $('#contents_iframe'); 
    3. $currentIFrame.contents().find(".wrap_contents").hide();
    4. $currentIFrame.contents().find(".greetings").fadeIn(2500);
}

this is my jquery syntax.

no.1 ~ 3, it works well.

but line no.4, it doesn't work.

structure of html document inside iframe is ...

<body>
    <div class="wrap_contents">
        <div class="greetings">
        </div>
        <div class="operational_philosophy">
        </div>
    </div>
    </body>
    </html>

what is the reason? what causes this problem?

and syntax of the parent html document is..

<iframe id="contents_iframe"></iframe>

what is the problem?? why can not find class inside class?

Upvotes: 3

Views: 5248

Answers (1)

Krish R
Krish R

Reputation: 22711

You may used jquery contents() function to access/find the elements,

$("#iframeID").contents().find("#contentID");

Upvotes: 4

Related Questions