I currently have the following code to make my FAQ buttons appear with the answer hidden until it is clicked. On click it shows the answer, but it leaves the answer expanded for each question when you click on another which eventually becomes way too long for the page as well as just being too much text on the page.
<script type="text/javascript">
function toggleMe(a){
var e=document.getElementById(a);
if(!e)return true;
if(e.style.display=="none"){
e.style.display="block"
}
else{
e.style.display="none"
}
return true;
}
</script>
<input type="button" onclick="return toggleMe('para1');" value="Question 1" class="buttonClass"><br>
<div class="button" id="para1" style="display:none" >
<br>Stupid, long answer
</div>
<br>
<input type="button" onclick="return toggleMe('para2')" value="Question 2" class="buttonClass"><br>
<div class="button" id="para2" style="display:none" >
<br>
Stupid, long answer 2
</div>
<br>
What I would like to happen is that when question1 is expanded and you click on another question, it not only expands that question, but would collapse question1.
TIA