使用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);这是为了“获取”目的。。。。