jQuery animate()

jQuery animate() method is used to perform a custom animation of a set of CSS properties.

Below the syntax of jquery animate() method


    • properties (default: 400)
    • Type: PlainObject
    • An object of CSS properties and values that the animation will move toward.

    • duration (default: 400)
    • Type: Number or String
    • A string or number determining how long the animation will run.

    • easing (default: swing)
    • Type: String
    • A string indicating which easing function to use for the transition.

    • complete
    • Type: Function()
    • A function to call once the animation is complete, called once per matched element.
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery animate()</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
$(document).ready(function() {
  $("#animation").click(function() {
     $("div").animate({left: '250px'});
 <button style="margin:0 0 10px 0" class="btn" id="animation">Start Animation</button><br />
 <div style="background:#11a286;height:120px;width:120px;position:absolute;"></div>