Description:
Jquery animation() method provide the custom animation with set of CSS properties.
Syntax
.animate( properties[duration ] [easing ] [complete ] ).animate( properties, options )
Ex :
1 |
$("#div").animate({ }); |
params | params parameter defines the CSS properties to be animated. |
Duration/speed | ย It specifies the speed of the fadein. The valuse may be slow, fast and milliseconds. (default value: 400).ย Durationย are given in milliseconds and higher values indicate slower animations, not faster ones. |
Easing | It specifies the easing function to be used for transition (default value: swing). |
Callback | A function to call once the animation is complete. |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#divflipBox").click(function () { $("#divpanelBox").animate({ height: '+=20px', width: '+=20px' }); }); }); </script> <style type="text/css"> #divflipBox, #divpanelBox { background-color: #a0ce4e; border: solid 1px black; width: 25%; } #divpanelBox { width: 30px; height: 30px; } </style> </head> <body> </br> <button id="divflipBox"> Click to Start Animation </button> </br> </br> <div id="divpanelBox"> </div> </body> </html> |
Output:
On Click ofย “Click to start animation” button, the “divpanelBox” started to append (css stlyle) the new height & width for the same and started to increasing the size of the div as shown below.
Leave A Comment