怎么向iframe中追加元素和事件呢

现在想想iframe里追加关闭按钮

<iframe id="iframe" class="iframe" src="https://www.imanet.org.cn/e/" frameborder="0" scrolling="no">
</iframe>

  var close='<div class="close-survey" onclick="closesurvey()"></div>'
           
    $('#iframe').contents().find('body').append(close)

这么写不行啊

阅读 4.8k
1 个回答
$('#iframe')[0].contentWindow.find('body')
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进