Change text (html) with .animate

后端 未结 7 2107
灰色年华
灰色年华 2020-12-23 20:04

I am trying to animate the html part of a tag ( This Text! ) using jQuery\'s Animate function, like so:

7条回答
  •  鱼传尺愫
    2020-12-23 20:35

    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:

    $("#test").html('The text has now changed!');
    $("#test").animate({left: '100px', top: '100px'},500);
    

    Check out this fiddle for full example:

    http://jsfiddle.net/Twig/3krLh/1/

提交回复
热议问题