I have a <div> with text.
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
I would like the text in this <div> appear on the page one character at a time:
L
Lo
Lor
... and so on, until the full text is visible
A valid alternative is to do this one word at a time to avoid problems with HTML objects and jumping words due to soft hyphenation.
If the user clicks on the <div> , he must cancel the animation and instantly display the full text.
In short, I want to imitate the animation that is often found in Japanese-style adventure games. (I think this is sometimes called a typewriter or teletype effect.) Here is a good example:
http://www.youtube.com/watch?feature=player_detailpage&v=SasgN0lim7M#t=418
Obviously, I can script animation using JavaScript - just set a timer and add letters (or words) one by one.
But is it possible to do what I need with CSS in modern browsers? (Of course, I need to at least change the class of the element in onclick using JS, but that's OK.)
Update: to clarify characters and letters and problems with HTML objects:
My text is littered with HTML:
Lo­rem <i>ip­sum</i>.
A naive approach with adding text to the innerHTML character will not work:
L
Lo
Lo &
... Doh!