You Are Here: Home »   Code Tuesday January 6th 2009

Code Library - js

Show And Hide Content - (1520 views)


<script language="javascript">
<!--
function collapse (id)
{
         if(!document.getElementById) { exit; }
         else { menu_id=document.getElementById(id);
                menu_id.style.display=(menu_id.style.display!="none")?"none":"block";

        }
}
-->
</script>

<!-- For a link to show/hide the content use: -->

<a href="javascript:collapse('id');">click here</a>

<!-- For the content you want to show/hide use: -->

<div style="display:block;" id="id">
** content here **
</div>

<!-- Just replace "id" with a name to identify the content -->