jQuery animate complete not working

The animation itself is working but why isn't my complete function working?

fiddle: https://jsfiddle.net/jzhang172/5kfbw066/1/

$(".ok").animate({
height:"300px"

},{
 duration:2000
 }, {complete:function(){
alert('hey');
}
});
.ok{
  background:blue;
  height:100px;
  width:200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="ok"></div>

Answers 1

  • complete is a property just as duration

    $(".ok").animate({
      height: "300px"
    
    }, {
      duration: 2000,
      complete: function() {
        alert('hey');
      }
    });
    .ok {
      background: blue;
      height: 100px;
      width: 200px;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div class="ok"></div>


Related Articles