Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery处理iframe_Jquery_Iframe - Fatal编程技术网

使用jquery处理iframe

使用jquery处理iframe,jquery,iframe,Jquery,Iframe,我想使用在iframe中单击的按钮执行一些jquery脚本,并且输出在iframe之外……可能吗???我的主要html如下所示: <html> <head></head> <body> <div id="test" >test</div> <iframe width="100px" height="100px" src="test.php" ><

我想使用在
iframe
中单击的按钮执行一些jquery脚本,并且输出在iframe之外……可能吗???我的主要html如下所示:

<html>
    <head></head>    
    <body>    
        <div id="test" >test</div>
        <iframe width="100px" height="100px" src="test.php" ></iframe>
    </body>
</html>

测试
对于test.php:

<html>
    <head>
        <script src="jquery.min.js" ></script>
        <script>
            $(document).ready(function(){
                $('#btn').click(function(){
                    $('#test').hide(); // i want to hide this whenever a button with id btn inside     and iframe is triggered
                });
            });
        </script>
    </head>
    <body>
        <button id='btn' >click</button>
    </body>
</html>

$(文档).ready(函数(){
$('#btn')。单击(函数(){
$(“#test”).hide();//每当触发id为btn的按钮和iframe时,我都要隐藏此选项
});
});
点击
我就是这么做的,但这不管用。谢谢你的建议……:)

您可以使用:-

$('#test', window.parent.document).hide();
您可以使用以下选项:-

$('#test', window.parent.document).hide();
您可以使用以下选项:-

$('#test', window.parent.document).hide();
您可以使用以下选项:-

$('#test', window.parent.document).hide();

Try:parent.$('#test').hide();Try:parent.$('#test').hide();Try:parent.$('#test').hide();Try:parent.$('#test').hide() 您可以使用
窗口。如果您的iframe和当前页面属于同一域,则可以使用父级
窗口。如果您的iframe和当前页面属于同一域,则无法使用父级
。如果您的iframe和当前页面属于同一域,则可以使用
窗口。如果您的iframe和当前页面属于同一域,则可以使用父级
无法工作。

如果您的iframe和当前页面属于同一域,则可以使用
window.parent
,否则它将无法工作。

它将使用$(“#test”,window.parent.document).val(xmlhttp.reponseText);它用于“获取”目的……它将使用$(“#test”,window.parent.document).val(xmlhttp.reponseText);它用于“获取”目的……它将使用$(“#test”,window.parent.document).val(xmlhttp.reponseText);它用于“获取”目的……它将使用$(“#test”,window.parent.document).val(xmlhttp.reponseText);它用于“获取”目的……它将使用$(“#test”,window.parent.document).val(xmlhttp.reponseText);它用于“获取”目的……它将使用$(“#test”,window.parent.document).val(xmlhttp.reponseText);它用于“获取”目的……它将使用$(“#test”,window.parent.document).val(xmlhttp.reponseText);它用于“获取”目的……它将使用$(“#test”,window.parent.document).val(xmlhttp.reponseText);这是为了“获取”目的。。。。