Accessing element in child IFrame from parent page using jquery

前端 未结 1 1634
迷失自我
迷失自我 2021-01-22 17:53

I am trying to access the elements of the document in the iframe from the parent document using the following code, but cannot get it to work for some reason.

Parent.htm

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-22 18:28

    Try using load instead of ready.

    $('#iframe1').load(function(){
        console.log($('#iframe1').contents().find("#testDiv").html());
    });
    

    0 讨论(0)
提交回复
热议问题