本文介绍了使用jQuery对将文本插入Div进行动画处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery是否可以使用animate来平滑地填充内容的div,即在插入内容时使div逐渐增大的高度的动画效果?

Is it possible with jQuery to use animate, to fill a div with content smoothly, i.e. animate the height of the div growling larger as I insert content?

例如(HTML):

 <div id="my-div"></div>

然后(JavaScript):

Then (JavaScript):

 $("#my-div").html("some new really long string of text which makes the div height increase.");

我想动画化html的插入,从而增加高度.

I would like to animate the insert of the html, and thus the height increase.

推荐答案

如果要真正为其中的文本设置动画,则必须缓慢地附加文本,一次添加一个字母.通过使用其他人已经提到的.slideDown()

If you want to truly animate the text in, you would have to slowly append the text, one letter at a time. You can get a similar effect by using what others have mentioned already, .slideDown()

http://jsfiddle.net/rkw79/fCAVp/

$("#my-div")
    .hide()
    .html("some new really long string of text ...")
    .slideDown('slow');

这篇关于使用jQuery对将文本插入Div进行动画处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 11:17