Collapsible Text
General
Display/hide information by just clicking a header. Previously opened section will be hidden when new one is opened. There is no limit to the amount of information you can add or sections you can use. Excellent for FAQs.
Notes
- Created by: Sandeep Gangadharan
- Web Site: http://www.sivamdesign.com/scripts/
- Posted: September 14, 2007
Each collapsible header has 2 DIV tags, one is the main header that opens or closes the collapsible text and the other is for the collapsible text or content. In the first DIV tag the text (onClick="openClose('a1')") should not be changed and in the second DIV tag the text (id="a1" class="texter") is required. As you add more collapsible headers the identifier 'a1' should be incremented for all new headers in both DIV tags, for example a2 for header 2, a3 for header 3 etc. Everything else can be modified as per your requirements.
Source Code
Paste this source code into the designated areas.
External file
Paste this code into an external JavaScript file named: collapsibleText.js
CSS
Paste this code into your external CSS file or in the <style> section within the HEAD section of your HTML document.
Head
Paste this code into the HEAD section of your HTML document.
Body
Paste this code into the BODY section of your HTML document


Leave a Response
(6 comments)I used it to hide a whole table of form fields that are optional, and used a checkbox with the onClick event. Worked great and code is so short. Great work.
I was thrown a last minute project and was given code that was not usable. I came to this site looking for collapsible text and this was EXACTLY what I needed! Wished I came here earlier on as I had another project - given even crappier code - that required collapsible lists and this would have been perfect.[br /][br /]blk
Not sure of the problem. It's all the same on this end.
The JavaScript in the sent email is not the same as on the site and does not work.
Been looking for something like this for a long time. Thanks. Will definitely use it in our FAQs page.