I am trying to animate the html part of a tag ( <font id="test" size="7">This Text!</font>
) using jQuery's Animate function, like so:
$("#test").delay(1500).animate({text:'The text has now changed!'},500);
However nothing happens, it does not change the text.
How can I do this? Thanks!
For fadeOut => change text => fadeIn effect We need to animate the wrapper of texts we would like change.
Example below:
HTML
JQuery JS
Hope this will help someone.
I was looking for something like that some days ago, but as I didn't had much time, I ended up using the easier fadeIn/fadeOut, as others had answered.
But the idea of animating text didn't left my mind and further I coded my own plugin (named jquery-bubble-text).
You can check it on github, or see this jsfiddle.
The syntax is the following:
Hope you enjoy it :)
If all you're looking to do is change the text you could do exactly as Kevin has said. But if you're trying to run an animation as well as change the text you could accomplish this by first changing the text then running your animation.
For Example:
Check out this fiddle for full example:
http://jsfiddle.net/Twig/3krLh/1/
Following the suggestion by JiminP....
I made a jsFiddle that will "smoothly" transition between two spans in case anyone is interested in seeing this in action. You have two main options:
The first time you click the button, number 1 above will occur. The second time you click the button, number 2 will occur. (I did this so you can visually compare the two effects.)
Try it Out: http://jsfiddle.net/jWcLz/594/
Details:
Number 1 above (the more difficult effect) is accomplished by positioning the spans directly on top of each other via CSS with absolute positioning. Also, the jQuery animates are not chained together, so that they can execute at the same time.
HTML
CSS
JavaScript
refer to official jquery example: and play with it.