在iframe的情况下,jQuery html()将失败
jQuery html() fails in case of 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的
<section>some text with mixed tags and an <iframe /> </section>
更新
当@Mike c(谢谢Mike)纠正我时,问题是你的自闭标签<iframe />
如果编写则有效
<article>
<section>some text with mixed tags and an <iframe></iframe> </section>
</article>
Fiddle
相关文章:
- 在iframe的情况下,jQuery html()将失败
- Html<输入模式>使用JavaScript处理-超过时失败
- 链接CSS、Javascript和HTML进程失败
- 当字符串包含 HTML 标记时,JSON 解析失败
- Powerbuilder/Javascript HTML数据窗口SetItem日期时间失败
- 尽管有onload函数,但替换内部HTML失败
- HTML多选失败
- js 中的 HTML 连接失败
- 更改$compile对象的 html 在 Angular 中失败
- HTML if 语句,用于在 CDN 失败时加载本地 JS/CSS
- 尝试追加 html 字符串失败与 jQuery
- 当参数包含 html 标记时,Ajax 调用失败
- 在jQuery中创建一个带有属性的HTML元素,在ie7和ie8中失败
- 使用 fs.readFileSync() 提供 html 文件失败
- 使用appendChild向HTML元素添加SVG元素-在IE9中失败
- Visual Studio Lightswitch HTML客户端验证失败
- 当内部的html被更改时,class.on(单击)失败
- Rails模式表单-在表单提交失败后,用html.erb文件中的内容更新弹出窗口
- 从HTML头加载层时,Dojo构建在IE9上失败:property'dir'未定义
- 程序失败- html和javascript之间的错误连接