Alternar (Mostrar / Ocultar) Elemento | Programar Plus

<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>

Uso en línea:

<a href="https://css-tricks.com/snippets/javascript/showhide-element/#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a>
<div id="foo">This is foo</div>
(Visited 9 times, 1 visits today)