Search This Blog

Wednesday 30 July 2014

Show/Hide HTML Tags using JavaScript

Show/Hide HTML div tags using JavaScript



<script type="text/javascript">
function showHide(divId)
{
    var theDiv = document.getElementById(divId);
    if(theDiv.style.display=="none")
  {
        theDiv.style.display="";
   }
   else
   {
        theDiv.style.display="none";
       }   
}
</script>

<input type="button" onclick="showHide('div1')" value="Test It">
<div id="div1" style="">
<h1>This is Demo</h1>
</div>

No comments:

Post a Comment