Hiding a div by default

前端 未结 7 1148
半阙折子戏
半阙折子戏 2021-01-01 10:28

I have a div that should be shown only when the user clicks the show button

$(\"div.toshow\").show();

I have written in the body

         


        
相关标签:
7条回答
  • 2021-01-01 11:12
    .toshow{
             display:none;
      }
    

    or

    .toshow{
           visibility:hidden;
             }
    
    0 讨论(0)
  • 2021-01-01 11:13

    You can use CSS display:

    .toshow
    {
        display: none;
    }
    
    0 讨论(0)
  • 2021-01-01 11:13
    $('#myDiv').hide();
    
    $("myDiv").css("visibility", "hidden");
    
    .toshow {
      visibility:hidden;
      display:none;
     }
    
    0 讨论(0)
  • 2021-01-01 11:14

    Yes you can can use style like this:

    <div class="toshow" style="display:none"></div>
    
    0 讨论(0)
  • 2021-01-01 11:24

    You can use jQuery to change the CSS styles of 'toshow' class adding "display: none". for example

    $(function(){
        $('.toshow').css("display", "none");
    });
    
    0 讨论(0)
  • 2021-01-01 11:26

    To do it in the body:

    <body>
    
    <div class="toshow" style="display:none">
    </div>
    
    </body>
    

    Although I would avoid inline css

    0 讨论(0)
提交回复
热议问题