I usually hide elements with
Code:
document.getElementById('element').style.display = 'none';
To have an element originally hidden, start with
Code:
<div style='display: none;' id='element'>Content</div>
So some sample code:
Code:
<script type='text/javascript'>
function show(obj, elId) {
var element = document.getElementById(elId);
if (element.style.display == 'none') {
obj.innerHTML = "-";
element.style.display = '';
}
else {
obj.innerHTML = "+";
element.style.display = 'none';
}
}
</script>
Code:
<div style='width: 100px; text-align: center; font-size: 18px; clear: both; float: left;' onclick="show(this, 'element1');">-</div>
<div id='element1'>
[Content1]
</div>
<div style='width: 100px; text-align: center; font-size: 18px; float: left;' onclick="show(this, 'element2');">+</div>
<div id='element2' style='display: none;'>
[Content2]
</div>
There are certainly many ways to do this, but this is the way I know the best. You could easily condense the JavaScript a little bit, but I wanted you to be able to understand it.
I tested this on FireFox and it seems to work fine (Minus the style part of the menu). However, it is untested in Internet Explorer (Which is going to be your major problem as far as browser cooperation goes).
Bruce