jQuery insertAfter从iFrame进入Parent

时间:2013-04-23 17:44:52

标签: jquery iframe

在父文件中我有:

<p id="successmsg">Text.</p>        
<iframe src="file.php" name="calcFrame"></iframe>

在file.php里面是:

<script>
jQuery(window.parent.document).ready(function() { jQuery('<p>Text to be inserted.</p>').insertAfter('#successmsg'); });
</script>

该脚本没有任何影响。我试过jQuery(文档)。我不确定我需要做什么,如window.parent.document让jQuery知道id在父页面内。

1 个答案:

答案 0 :(得分:2)

试试这样:

$('#successmsg', window.parent.document).after('<p>Text to be inserted.</p>');

Jsbin example

相关问题