jQuery animate () method
Examples
By changing the height of an element, the element of animation application:
$("#box").animate({height:"300px"});
});
try it"
Definition and Usage
animate () method to perform a custom animation CSS attribute set.
In this method, the CSS style elements to change from one state to another. CSS property value is gradually changing, so you can create animation effects.
Only numeric values can create animations (such as "margin: 30px"). String value can not create animations (such as "background-color: red").
Tip: Use the "+ =" or "- =" to create a relative animation.
grammar
参数 | 描述 |
---|---|
styles | 必需。规定产生动画效果的一个或多个 CSS 属性/值。 注意: 当与 animate() 方法一起使用时,该属性名称必须是驼峰写法: 您必须使用 paddingLeft 代替 padding-left,marginRight 代替 margin-right,依此类推。 可以应用动画的属性:
|
speed | 可选。规定动画的速度。 可能的值:
|
easing | 可选。规定在动画的不同点中元素的速度。默认值是 "swing"。 可能的值:
|
callback | 可选。animate 函数执行完之后,要执行的函数。 如需学习更多有关 callback 的内容,请访问我们的 jQuery Callback 这一章。 |
Alternate Syntax
参数 | 描述 |
---|---|
styles | 必需。规定产生动画效果的一个或多个 CSS 属性/值(同上)。 |
options | 可选。规定动画的额外选项。 可能的值:
|
Try - Example
Use animate with callback function ()
How to use with a callback function animate () to repeat the animation.