Social Icons

Pages

dimanche 11 août 2013

Hide Show DIV Content with Links by using Javascript

The Hide and Show DIV elements for HTML content is a great way to clean up your sidebar. It becomes especially handy for those long blogroll lists or anything that clutters up the blog. Just simply click a link to make all the hidden content magically appear and disappear.

Demo:

+/- Click Here to Expand and Collapse

How to use it in Your Blog

Step 1: Adding CSS and Javascript
First, add this code below directly above the 
 tag.


Step 2: Adding the Active Content to be Displayed
Place this code wherever you would like it to appear. Make sure to change the red text to a name that is "unique" to any other name in your template. An example might be "blogroll-dropdown". If you do not give each Hide Show DIV element a unique name the script cannot be used more than once on the same page. The green text is the title of the link that you click on to make the content appear. Replace the code "Expanded Content" with the content you wish to have expand and collapse.
UniqueName
')"
>Link Title

UniqueName
"
>Expanded Content
Step 3: Sample Code
Here is what my code looks like for the demo above:
hideshowdemo
')">+/- Click Here to Expand and Collapse
hideshowdemo
">

Aucun commentaire:

Enregistrer un commentaire

 

Sample text