Show or Hide Anything HTML Javascript

Nov 29th, 2009 | Filed under Code

On my website I had about seven offensive t-shirt thumbnails i wanted to hide in a divider. So I ended up making this bit of code.

You can use this to show and hide anything on the page. The default for this code is that it is first hidden, then you open it. By cliking on a hyperlink.

This is the code for showing and hiding a Divider:

<script type=”text/javascript”>
<!–
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == ‘block’)
e.style.display = ‘none’;
else
e.style.display = ‘block’;
}
//–>
</script>

<a onclick=”toggle_visibility(‘foo’);”> <p align=”left”  style=”font-size:19px”><strong><br />
<br />
Click Here For The Hidden Divider Foo</strong><br />
<p>&nbsp; </p></a>

<div id=”foo” style=”display:none”>

This Is Foo

</div>


Click Here For The Hidden Divider Foo

No comments yet.