Files
freeCodeCamp/guide/chinese/jquery/jquery-animate/index.md
2018-10-16 21:32:40 +05:30

30 lines
852 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: jQuery Animate
localeTitle: jQuery Animate
---
## jQuery Animate
jQuery的animate方法只需几行代码就可以轻松创建简单的动画。基本结构如下
```javascript
$(".selector").animate(properties, duration, callbackFunction());
```
对于`properties`参数您需要传递一个javascript对象并将要作为键设置动画的CSS属性以及要作为值设置为动画的值。 在此`duration`您需要输入动画应采用的时间量(以毫秒为单位)。 动画完成后执行`callbackFunction()`
### 例
一个简单的例子如下所示:
```javascript
$(".awesome-animation").animate({
opacity: 1,
bottom: += 15
}, 1000, function() {
$(".different-element").hide();
});
```
#### 更多信息:
有关更多信息,请访问[官方网站](http://api.jquery.com/animate/)