Connecting Tech Pros Worldwide Forums | Help | Site Map

How to show/hide classes using CSS and or javascript?

Newbie
 
Join Date: May 2007
Location: Texas
Posts: 9
#1: 3 Weeks Ago
I want to be able to stop a paragraph mid-sentence and provide a 'more' link that then disappears when clicked and the rest of the paragraph appears in place. Much like many blogs and social sites do.

Below is code from just such a site... so what is needed to make it work?
Expand|Select|Wrap|Line Numbers
  1. <div id="story" class="text_exposed_root">Yay for being around yada
  2.  
  3. <span class="text_exposed_hide">...</span>
  4.  
  5. <span class="text_exposed_show"> yada on Sunday!</span>
  6.  
  7. <span class="text_exposed_hide">
  8. <span class="text_exposed_link">
  9. <a onclick="CSS.addClass($("story"), "text_exposed");">read more</a>
  10. </span>
  11. </span>
  12. </div>
Thanks for any help.

drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,573
#2: 3 Weeks Ago

re: How to show/hide classes using CSS and or javascript?


Obviously, with the 'onclick' attribute, you need javascript and you should ask this question on that board.

Actually, something can be done without js by assigning CSS to the anchor's ':visited' property but that can be unreliable and only works on one click.
Reply

Tags
css.addclass, exposed