Expand & Collapse Layers

This page presents an even easier solution to the question of how to easily expand and collapse a list without knowing much Javascript. I've already worked up an example of how to do this using unordered lists. This example uses divs.

The code is from blakems.com. Insert this code into the HEAD section of the page, then set up the divs and you're done!

<script language="JavaScript">
function expandCollapse() {
for (var i=0; i<expandCollapse.arguments.length; i++) {
var element = document.getElementById(expandCollapse.arguments[i]);
element.style.display = (element.style.display == "none") ? "block" : "none";
}
}
</script>

Example



See a live example of this technique at the Arizona Smokers' Helpline FAQ page.

<- back to index | ©2006 clg.