Forum Moderators: open

Message Too Old, No Replies

html collapse & expand

         

earthgreen

7:52 am on Aug 4, 2008 (gmt 0)

10+ Year Member



I need very simple html script to make text collapse
and expand

for example when click the title it expand the articles.

please help

tedster

8:24 am on Aug 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This kind of effect may not end up being quite as "simple" as you hoped for, although the basic concept is pretty straightforward - a combination of html, css and javascript. Javascript accesses the DOM for a div that holds the initially invisible content. Then an onclick event changes the CSS style for that div from display:hidden to display:block - and possibly back again. Or in some layouts you may switch from visibility:hidden to visibility:visible

This is commonly called "show/hide divs" or sometimes "show/hide content". The topic is really one for our Javascript forum rather than here in the HTML forum. There are already many threads you can reference on the topic. Try our site search [google.com] to see the available threads.

sleidia

9:12 am on Aug 6, 2008 (gmt 0)

10+ Year Member



Hi earthgreen.

I've spent a few hours searching for this kind of script (the animated type) for a project of mine and, the best one I've found takes the shape of three JS files that you can find easily with Google :

prototype.js
scriptaculous.js
effect.js

Then, you use this snippet :

function id_toggle ( targetId ) {

if (document.getElementById(targetId).style.display != "none")
Effect.BlindUp(targetId);
else
Effect.BlindDown(targetId);

}

sleidia

9:15 am on Aug 6, 2008 (gmt 0)

10+ Year Member



ooops, it's effects.js

But you can get those three files just by downloading Lightbox.