如何使用Jquery在单击iframe时隐藏它 [英] How to hide a iframe upon clicking on it with Jquery

查看:393
本文介绍了如何使用Jquery在单击iframe时隐藏它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jquery隐藏iframe.当用户点击iframe(例如包含Google ADD的iframe)时,它应该隐藏而不干扰iframe代码.我该如何使用Jquery做到这一点.

How to hide a iframe with jquery. When user click on iframe (example iframe containing a google ADD ) it should hide without disturbing the iframe code. How can i achieve this with Jquery.

谢谢

推荐答案

我将在iframe(位于您的页面上)的外部有一个ID为"toggle"的链接:

I would have a link with id "toggle" right outside the iframe (on your page):

<a href="javascript:void(0);" id="toggle">-<span style="display:none">+</span></a>

以下是使用jquery进行链接以隐藏广告的方法:

Here's how you would link that up to hide the ad using jquery:

<script type="text/javascript">
    $(function(){
     var toggler=$("#toggle");
     toggler.click(function(){
      $("iframe").slideToggle('slow', function(){
         // or specify a specific iframe using $("#iframe_id")
        $("#toggle span").toggle();
      });
     });
    }); 
</script>

这篇关于如何使用Jquery在单击iframe时隐藏它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆