CoderZone.org

Category: >> JavaScript >> Hide/Show div Bookmark and Share

<< lastnext >>

Snippet Name: Hide/Show div

Description: Toggles the display of a div (can also be used on a SPAN).

Comment: (none)

Author: CoderZone
Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: March 01st, 2009

< s c ript type="text/javascript">
 
function toggle_div(id) {
     var diq = document.getElementById(id).style;
     diq.display=(diq.display=="none") ? "" : "none";
 
}
 
</script>
 
<!-- Example usage -->
<a href="javascript:toggle_div('hideshow')">Hide/show</a>
 
<div id="hideshow">
     <h1>Example text to hide or show</h1>
</div>
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 5