Wednesday, January 13, 2010

How to hide/show Div content using JavaScript

<html>

<head>
<script language="javascript">
     
          function div1()
          {
            document.all.divA.style.display = 'none';
            document.all.divB.style.display = 'block';
          }
        
          function div2()
          {
            document.all.divB.style.display = 'none';
            document.all.divA.style.display = 'block';
          }
       
</script>
</head>
<body>

<div id="divA" onclick="div1()">Div One Contect</div>

<div id="divB" onclick="div2()" style="display:none">Div One Contect</div>

</body>
</html>




In using this code you can hide and show div tags. this is wrote the way only one content is available at one time.
Post a Comment