Thursday, October 2, 2014

Get callback after height animation using jQuery.

First link jQuery file in the example.

<script type="text/javascript" src="jquery-1.11.1.min.js"></script>

<style type="text/css">

#btn1{
   background: #321321;
   color: white;
   border-radius:3px;
   border: 1px solid;
   height: 35px;
}
#box{
   background:#c87bb9;
   height:100px;
   width:100px;
   margin:6px;
}

</style>

<button id="btn1">Start Animate</button>
<div id="box"></div>

<script type="text/javascript">

$(function(){
   $("#btn1").click(function () {
       $("#box").animate({
           height: "300px"
       }).promise().done(function(){
           alert('animation is finished');
       });;
   })
});

</script>


Output :)

1)

2)

No comments:

Post a Comment