How to hide a div in html?

时间:2015-05-24 21:39:19

标签: html

Is it possible to hide and show a complete DIV with Content in HTML, Just hide the DIV when the page is loaded and show it again if a button is pressed? I'm sorry i am new with this this, so don't take me wrong!

2 个答案:

答案 0 :(得分:2)

You can use Jquery to hide and show contents using the Toggle function. I'm new here and new to programming but try this out.

"This goes in the head element"

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

// code

$(document).ready(function() {
  $(".divsubcontent class").hide();         
  $(".divcontentheader").click(function() {
    $(this).next().animate(
      {
        height: "toggle",
        opacity: "toggle"
      },
      {
        duration: 600
      }
    );
  });
});

remember to put this jquery code in a file called jquery.js and link it.

im sorry if this didnt help but its something like this

答案 1 :(得分:-1)

Use a css style class for hiding your DIV like :

<div style="display:none;"> Your content </div>

And for showing your div you can use jQuery