In this article, we will explain how to use animate() method in jQuery with example.

jQuery animate() method use to animate a particular html element  where we need to pass different css animation attributes separated by comma (,). In general animations are performed on only those CSS properties that are specified in numberic values, eg. width, height  etc.

 $(selector).animate({params}, speed, callback);

The params parameter defines the CSS properties to be animated.

The speed parameter is optional and specifies the duration of the effect. It can be set as "slow" , "fast" or milliseconds.

The callback parameter is also optional and it is a function which is executed after the animation completes.

Let's take a simple example to see the animation effect.

<!DOCTYPE html>
<html xmlns="">
    <title>Jquery Tutorials</title>
    <script type="text/javascript" src=""></script>
        $(document).ready(function () {
            $(document).ready(function () {
                $("#btnAnimate").click(function () {
                        width: "400px",
                        height: "200px"
                    }, 500);
    <input type="button" id="btnAnimate" value="Start Animation"/><br /><br />
    <div id="divAnimate" style="width: 200px; height: 80px;background-color: red; position: absolute;">

 Let's check live example

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like