Download "Show/Hide content" script

Demo

Put this into your <HEAD> section

Put this example code into your <BODY> section

How to use

You define your questions and answers like this:
<div id="q1" class="question">- How does this work ?</div>
<div id="a1" class="answer">This is done by use of <divs> and altering the css attribute "display"</div>

I.e. two simple divs, where the first one got the id "q1" and the second one the id "a1". "1" indicates that this is the first question. Q&A number 2 should have the id "q2" and "a2". The first div should be assigned to the class "question" and the second one the "answer" class.

The script is initialized by the initShowHideContent() function. This function is executed as an window onload event. If you allready have a onload event, you could replace the line window.onload = initShowHideContent; with either <BODY onload="initShowHideContent()"> or a direct call to the function below your last q&a divs. example:
<SCRIPT type="text/javascript">
initShowHideContent()
</SCRIPT>

Comments

No one has commented this - be first!

Post your comment

Don't have an avatar? Create one at Gravatar.com.

Confirmation code:

Go to cbolson.com


About/Contact | A good idea? | Submit a script | Privacy notice
© 2005 - 2024 dhtmlgoodies.com