如何使用 jQuery 访问 iframe 的内容? [英] How to access the content of an iframe with jQuery?
本文介绍了如何使用 jQuery 访问 iframe 的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 jQuery 访问 iframe 的内容?我试过这样做,但它不起作用:
How can I access the content of an iframe with jQuery? I tried doing this, but it wouldn't work:
iframe 内容: <div id="myContent"></div>
jQuery: $("#myiframe").find("#myContent")
我如何访问 myContent
?
类似于 jquery/javascript:访问内容一个 iframe 但接受的答案不是我想要的.
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 访问 iframe 的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文