Description:
The jQuery delay() method is used to delay the execution of animation in the queue. It is a best method for delay between the queued jQuery effects.
Syntax
.delay( speed )
Ex :
1 |
$("#div").delay("1000") |
Duration/speed | It specifies the speed of the delay. Its possible vales are slow, fast and milliseconds. |
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 39 |
<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 () { $("#divpanelBox1").slideDown().delay(1000).fadeOut(); $("#divpanelBox2").slideDown().delay(200).fadeOut(); }); }); </script> <style type="text/css"> #divflipBox, #divpanelBox { background-color: #a0ce4e; } #divpanelBox1 { width: 90px; height: 90px; background-color: blue; } #divpanelBox2 { width: 90px; height: 90px; background-color: red; } </style> </head> <body> <button id="divflipBox"> Click to Apply DELAY() </button><br><br> <div id="divpanelBox1"> </div><br> <div id="divpanelBox2"> </div> </body> </html> |
Output:
After clicking the “Click to slide down using DELAY()” button, the “divpanelBox1” slides downย immediatelyย and delay/pauseย for 1000 milliseconds for next execution(ie.,fadeOut). In ย the same way,ย “divpanelBox2” will make pause for 200 milliseconds for fadeOut().
Leave A Comment