javascript - jQuery html() 在 iframe 中失败?

标签 javascript jquery iframe

实际上,jQuery(v1 和 v2 - 最新版本)面临着非常奇怪的行为。 我有一个管理内容的脚本,但当内容包含 iframe 时它会失败。

<article>
   <section>some text with mixed tags and an <iframe /> </section>
</article>

<script>
$('section').each(function() {
   console.log( $(this).html() )
});
</script>

这将返回未定义

我是否缺少一些在这些情况下使用的解决方法?

最佳答案

iframe 的 open 标签在哪里?

<section>some text with mixed tags and an <iframe /> </section>

更新

正如@Mike c(谢谢迈克)纠正我的问题是你的自闭标签 <iframe />

关于javascript - jQuery html() 在 iframe 中失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37171068/

相关文章:

javascript - 如何从头开始设置 Twitter typeahead?

javascript - 使用 JavaScript 使用 JSON 填充 HTML

javascript - Handlebars js不遍历对象

jquery - 如何使用 jQuery 更新选择选项?

javascript - 导出服务器端函数供客户端使用

php - 使用 XmlHttpRequest 发出 DELETE 请求

css - 使用 CSS 媒体查询改变 YouTube 视频质量

jquery - 悬停在 IE9 中无法与 iFrame 配合使用

javascript - Three.JS 线框 Material - 所有多边形与仅边缘

java - 我们可以使用 selenium Webdriver 访问 ICICI、HDFC、SBI 等银行网站的 Web 元素以实现自动化吗?