Abhishek Pundir Abhishek Pundir - 4 months ago 11
CSS Question

how to make visible a div which is initially hidden by clicking on button using javascript

I want that my hidden div will be visible continuously after clicking the button.

This is my js code:

document.getElementById("share").onclick=function show(){
document.getElementById("taskdiv2").style.visibility='visible';
};


This is my html code:

<a id="share" onclick="show()" type="button" class="btn btn-lg btn-default" href="">Share</a>

<div id="taskdiv2" style="visibility:hidden" class="row">
hiiiii !this is vivek.
</div>

Answer

try this out :

    function becomevisible() {
      document.getElementById("div").style.opacity="1";
      }

<!-- language: lang-css -->

    div {
      background:red;
      height: 100px;
      width: 100px;
      opacity: 0;
      }



    <div id="div">Test</div>
    <button onclick="becomevisible()">See the div!</button>