Thursday, July 28, 2011

Simple method to show/hide using javascript


  • Place this script at the beginning of the html code:

<script type="text/javascript">

function showhide(ThisObj)

{

      nav=document.getElementById(ThisObj);

      if(nav.style.display=="none")

          nav.style.display='block';

      else

          nav.style.display='none';

 }

</script>

  • Give a link (either a plus sign or some text or even a button) for the content to be shown or hidden:

<div onclick="showhide('step')" >link name</div>

  • The content to be shown or hidden (expanded) needs to be placed within this div tag:

<div id="step" style="display: none;"> content to be shown and hidden </div>

No comments:

Post a Comment