通过jquery选择器访问iframe中的变量 [英] Access to a variable in an iframe by jquery selector
本文介绍了通过jquery选择器访问iframe中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下内容:
<iframe id="test">
<script>
variable='hi';
</script>
</iframe>
我需要知道如何通过jquery选择器从顶部窗口访问变量,如$ (#test)。变量?
I need to know how can I access to a variable by jquery selector from the top window like this $("#test").variable ?
推荐答案
您可以尝试:
$("#test")[0].contentWindow.variable;
这篇关于通过jquery选择器访问iframe中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文