Hide iframe by default

On one of the pages I need to have an iframe, but when the user loads the page, I want it to be hidden by default. Right now I have a hide and show button to hide and show the iframe, but it displays by default. How can I hide it by default?

Here is the code I have for two buttons

<input type="button" value="Show Graph" onClick="$('graph').show();">
<input type="button" value="Hide Graph" onClick="$('graph').hide();">
+3
source share
5 answers

Have you tried using CSS like this?

iframe {
   display:none;}

Although it depends on whether you also want to reserve the area. Using a sketch would be easier to find out.

You can hide and load using jQuery.

function(){$('graph').hide();}
+6
source

Also, since you are already using jQuery, you can simply hide the iFrame on the page load as follows:

<script type="text/javascript">
$(document).ready(function()
{
     $('#graph').hide();
});
</script>

:

:

Iframe:

id="graph" iframe.

onClick:

onClick="$('#graph').show();" onClick="$('#graph').hide();"

+3

<head>,

<script type="text/javascript">
$(function() {
    $('graph').hide();
});
</script>

, 'graph' - jQuery, <graph>; '#graph' iframe id "graph"

0

:

  • 0.

  • iframe (, "hideframe" ),

    #hideframe{display: none;}
    
  • jQuery

    $(document).ready(function(){        
       $("#hideframe").css("display", "none");        
    });
    

    $(document).ready(function(){
        $("#hideframe").hide();
    }); 
    

, jQuery . , , - jQuery. , URL- jQuery , , .

0

I don't have enough time ... but you can make a self-call to the jQuery function as follows

(function (){ $('iframe').hide(); })();

0
source

Source: https://habr.com/ru/post/1788041/