Javascript 隐藏iframe直到单击链接,然后在单击链接后隐藏链接
我有这个代码在iframe中打开链接Javascript 隐藏iframe直到单击链接,然后在单击链接后隐藏链接,javascript,jquery,iframe,Javascript,Jquery,Iframe,我有这个代码在iframe中打开链接 <a href="http://www.example.com/" target="iframe1">link</a> </br></br> <iframe id="iframe1" name="iframe1" src="#"></iframe> 我想隐藏iframe,直到单击链接,然后在单击链接后隐藏链接 我需要用javascript/jQuery来实现这一点 谢谢将链接
<a href="http://www.example.com/" target="iframe1">link</a>
</br></br>
<iframe id="iframe1" name="iframe1" src="#"></iframe>
我想隐藏iframe,直到单击链接,然后在单击链接后隐藏链接
我需要用javascript/jQuery来实现这一点
谢谢将链接放入Span标记中,然后执行以下操作:
$("#link").click(function(e) {
e.preventDefault();
//Assuming you're assigning the source dynamically, if not, comment out below line.
$("#iframe1").attr("src", $("link").attr("value");
$("#iframe1").show();
$("#linkBeGone").hide();
});
<div id="linkDiv">
<a href="#" id="theLink">Link</a>
</div>
<br/><br/>
<iframe id="iframe1" name="iframe1" src="#"></iframe>
$(document).ready(function(){
$("#iframe1").hide();
$("#theLink").click(function(){
$("#iframe1").show();
$("#linkDiv").hide();
return false;
});
});
将链接“#”的href属性设置为“#”,并将该值设置为希望iFrame成为的src
<span id="linkBeGone"><a id="link" value="http://www.example.com/" href="#" target="iframe1">link</a></span>
</br></br>
<iframe id="iframe1" name="iframe1" src="#"></iframe>
我将执行以下操作:
$("#link").click(function(e) {
e.preventDefault();
//Assuming you're assigning the source dynamically, if not, comment out below line.
$("#iframe1").attr("src", $("link").attr("value");
$("#iframe1").show();
$("#linkBeGone").hide();
});
<div id="linkDiv">
<a href="#" id="theLink">Link</a>
</div>
<br/><br/>
<iframe id="iframe1" name="iframe1" src="#"></iframe>
$(document).ready(function(){
$("#iframe1").hide();
$("#theLink").click(function(){
$("#iframe1").show();
$("#linkDiv").hide();
return false;
});
});
$(文档).ready(函数(){
$(“#iframe1”).hide();
$(“#链接”)。单击(函数(){
$(“#iframe1”).show();
$(“#linkDiv”).hide();
返回false;
});
});