
"As seen on TV!"
A very effective infomercial! I wanted to order a dozen, for all my classical-music-loving friends!
Almost as funny as this one!
One of the most frequently used constructions in javascript are functions that toggle styles or properties on and off. This can be used for items that require a highlighting effect, or to create layers that expand or contract, or any other property change where you want a property of an element to toggle on and off depending on its current state.
Put this in the head of the document:
<script>function toggle(id){
var element = document.getElementById(id);
element.style.display = (element.style.display == 'block') ? "none" : "block";
}
</script>
Create the trigger for the toggle:
<a href="javascript: toggle('myElement');">Open/Close</a>
Create the element you want to toggle open and closed:
<div id="myElement" style="display:block"> content goes here </div>