Temaska
Temaska

Reputation: 317

jQuery access to frame inside iframe on fully loaded frame

Need get access to element inside in frame inside in inframe with jQuery.

I have this struct:

<iframe id="frame1">
  <frameset id="frameset">
    <frame id="frame2"> <div id="exampleDiv">text</div> </frame>
  </frameset>
</iframe>

and script:

$("#frame1 #frameset #frame2").load(function () {
    $('#exampleDiv').hide();
});

but this script is not working

Upvotes: 2

Views: 2177

Answers (1)

Chuck Mah
Chuck Mah

Reputation: 638

you should use the jquery content() to retrieve the content of an iframe then use the .find() method but the document in the frame should be in the same domain that the parent document.

in this case :

 $("#frame1").contents().find("#exampleDiv").hide()

Upvotes: 1

Related Questions