Angelica Kosasih
Angelica Kosasih

Reputation: 11

jquery hide/show hide content when open page

I'd like the content to be hidden when I first open the page until the button is clicked. Any help?

<script>
$(document).ready(function(){
$("#rooms").click(function(){
    $("#rooms_box").show();
});
$("#facilities").click(function(){
    $("p").show();
});
 $("events").click(function(){
    $("p").show();
});
 $("#gallery").click(function(){
    $("p").show();
});
 $("#contact").click(function(){
    $("p").show();
});
 $("#search").click(function(){
    $("p").show();
});
});
</script>

Upvotes: 1

Views: 543

Answers (1)

Mohamed-Yousef
Mohamed-Yousef

Reputation: 24001

use it like this

<script>
$(document).ready(function(){
   $("p , #rooms_box").hide(); // instead of this line you can use the css below
   $("#rooms").click(function(){
     $("#rooms_box").show();
   });
   $("#facilities, #events , #gallery, #contact ,#search").click(function(){
       $("p").show();
  });
});
</script>

and its good to use css

p , #rooms_box{
   display : none;
}

Upvotes: 1

Related Questions