2017-03-01 84 views
0

我有一个div改变内部的iframe的内容,并删除不需要的元素

<div id="container"> 
<iframe id="survey" src="somepage"></iframe> 
</div> 

现在的iframe

我想删除除iframe内的一个div所有其他项目里面的页面加载

$("#container").html($("#survey .requiredDiv").html()) 

但是,这是行不通的

是否有可能做这种事?应该做什么?

+1

您是否尝试过'而不是:

然而,你可以使用负载/ HTML这样的方式:

$("#container").html(function(){ // There could be multiple target elements, i guess you should loop and return the html var htm = ''; $("#survey").contents().find(".requiredDiv").each(function(){ htm += this; }); return htm; }); 

使用​​? 'var frame = $('#survey')。contents();' –

+1

你读过这个吗? http://stackoverflow.com/a/15556150/7599559 –

回答

1

请记住:srciframe也应该在同一个域中。这是出于安全原因。使用`内容()

$("#container").load($("#survey").contents().find(".requiredDiv")); 
相关问题