Example of .delay() in jQuery
April 30, 2013
.delay() in jQuery, delayes the task execution for a the fixed time. .delay() works as a timer. In our example there is a .delay() which will stop execution for the given time.
.delay(time)
<!DOCTYPE html> <html> <head> <style> div { position: absolute; width: 50px; height: 50px; float: left; } .first { background-color: red; left: 0;} </style> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> </head> <body> <p><button>Start</button></p> <div class="first"></div> <script> $("button").click(function() { $("div.first").slideUp(300).delay(500).slideDown(400); }); </script> </body> </html>
Output