$.animate promise test

by wittnl

HTML

<div id="square"></div>

CSS

div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
    background: red;
}

JavaScript

$(document).ready(function() {
    var sq = $("#square");
    
    (function animate() {
        sq.css({top: 0}).animate({top: "100%"}, 1000);   
    })();
    
    sq.promise().done(function() {
        console.log("Derp");
    });
});