Jump to content
xisto Community
Sign in to follow this  
Grafitti

Javascript Show / Hide Functions need some fine-tuning

Recommended Posts

Searching before posting my topic, i found this very helpful post.
Javascript show + hide
However, I'm still muddling around trying to fine tune it, and since i'm no good at coding, I'd appreciate any help.
Using that example, how do I get the div text to be hidden on loading, rather than showing it all at page load.
Also, is there a way to have the text change when clicked? so that for example, it would say "expand" when it's the small amount of text, and "collapse" when it's the full text?

Share this post


Link to post
Share on other sites

For the DIV you want to be hidden completely right away, use display: none in your CSS file. As for the expand/collapse like, I guess you could use something like this:

 

<a href=..... id=operation>Collapse</a>
Then, in the code that expands and collapses the DIV you should add:

 

document.getElementById("operation").innerHTML = "Expand";
This way you will change the text to "Expand" after collapsing the DIV, and the opposite when expanding it :ph34r:

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.