开发者

How to hide a iframe upon clicking on it with Jquery

开发者 https://www.devze.com 2023-02-07 04:02 出处:网络
Ho开发者_Python百科w 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 Jq

Ho开发者_Python百科w 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.

Thank You


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>

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消