【问题标题】:How to hide a iframe upon clicking on it with Jquery如何在使用 Jquery 单击 iframe 时隐藏它
【发布时间】:2011-06-17 16:18:38
【问题描述】:

如何使用 jquery 隐藏 iframe。当用户单击 iframe(包含 google ADD 的示例 iframe)时,它应该隐藏而不会干扰 iframe 代码。我怎样才能用 Jquery 实现这一点。

谢谢

【问题讨论】:

  • 只需付钱就可以搭上谷歌广告
  • @Mauricio LOL 对 .. @KillerFish Dude 不要尝试使用谷歌 .. 如果你打算这样做。
  • 忘掉 google add 吧。至少你可以在点击时用 jquery 隐藏 iframe。谢谢

标签: jquery iframe hide


【解决方案1】:

我会在 iframe 之外(在您的页面上)有一个 ID 为“toggle”的链接:

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

以下是您如何使用 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-29
    • 2015-10-05
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    相关资源
    最近更新 更多