Set A Timer To Delay Execution Of Subsequent Items In The Queue
Maybe your like
jQuery Effect : Exercise-3 with Solution
Set a timer to delay execution of subsequent items in the queue.
Sample Data : HTML code:
<body> <button id="btn1">Start Animate</button> <button id="btn2">Stop Animate</button> <div id="box" style="background:#5858FA;height:100px;width:100px;margin:6px;"></div> </body>Solution:
HTML Code:
<!DOCTYPE html> <html> <head> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <meta charset="utf-8"> <title>Set a timer to delay execution of subsequent items in the queue</title> </head> <body> <p>delay() method sets different speed values.</p> <button>Click to fade in boxes with a delay</button></p> <div id="div1" style="width:100px;height:90px;display:none;background-color:#9F81F7;"></div><br> <div id="div2" style="width:100px;height:90px;display:none;background-color:#0B610B;"></div><br> <div id="div3" style="width:100px;height:90px;display:none;background-color:#61210B;"></div><br> </div> </body> </html>JavaScript Code :
$("button").click(function(){ $("#div1").delay(800).fadeIn(); $("#div2").delay(2400).fadeIn(); $("#div3").delay(4000).fadeIn(); });Note: delay( duration [, queueName ] ) method is used to set a timer to delay execution of subsequent items in the queue. It has the following parameters :
- duration : An integer represents the number of milliseconds to delay execution of the next item in the queue. [Type: Integer]
- queueName : A string containing the name of the queue (Default -> fx, the standard effects queue). [Type: String]
Go to:
- jQuery Effects Exercises Home ↩
- jQuery Exercises Home ↩
PREV : Stop an Animation. NEXT : Use dequeue to end a custom queue function which allows the queue to keep going.
Live Demo:
See the Pen jquery-effect-exercise-3 by w3resource (@w3resource) on CodePen.
Contribute your code and comments through Disqus.
Tag » Add Delay Animate Jquery
-
.delay() | JQuery API Documentation
-
Can I Use .delay() Together With .animate() In JQuery? - Stack Overflow
-
Delay JQuery Animation By Few Seconds
-
JQuery Effect Delay() Method - W3Schools
-
Delay Animations In JQuery - TutorialsPanel
-
Jquery Animate Delay Code Example - Code Grepper
-
Delay With Animation Jquery Code Example - Code Grepper
-
Learn To Use JQuery .delay() To Manage Your Effect Queues Better
-
JQuery Delay() Function - JournalDev
-
Animating Numeric Properties With JQuery - Khan Academy
-
Animation-delay - CSS: Cascading Style Sheets - MDN Web Docs
-
How To Delay Animation In JQuery? - Quick
-
What Is The Use Of Delay() Method In JQuery ? - GeeksforGeeks
-
How To Delay Jquery Animation - ITecNote