jquery - 如何使用 jQuery 访问 iframe 的内容?

标签 jquery iframe

如何使用 jQuery 访问 iframe 的内容?我试过这样做,但行不通:

iframe 内容: <div id="myContent"></div>

jQuery: $("#myiframe").find("#myContent")

如何访问 myContent


Similar to jquery/javascript: accessing contents of an iframe but the accepted answer is not what I was looking for.

最佳答案

你必须使用 contents() 方法:

$("#myiframe").contents().find("#myContent")

来源:http://simple.procoding.net/2008/03/21/how-to-access-iframe-in-jquery/

API 文档:https://api.jquery.com/contents/

关于jquery - 如何使用 jQuery 访问 iframe 的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1796619/

相关文章:

javascript - 如何在单击元素时选择值

javascript - 如何使用HTML数据属性返回对象数据?

jQuery 使用 startswith 公共(public)字符串按 ID 选择多个 div 元素

html - 带有 css 固定位置 : possible? 的 iframe

javascript - Handsontable:关闭自动调整行的大小(如何设置固定高度?)

javascript - iframe 调用父级 javascript

python - 在python中获取iframe内容

python - 问 : How can I create dynamically an iframe inside a web content using Python?

javascript - 为什么我可以在第一次尝试时从 iframe 写入 sessionStorage,但不能连续尝试? (Chrome 版本 74)

javascript - 如何解决悬停时图像链接的问题?