Javascript examples for jQuery Method and Property:queue
The queue() method returns the effect queue for the selected elements.
$(selector).queue(queueName);
Parameter | Require | Description | Value |
---|---|---|---|
queueName | Optional. | name of the queue | Default is "fx", the standard effects queue |
The following code shows how to Display the length of a queue in a <span> element:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var div = $("div"); startAnimation();/*from w ww.jav a 2 s . co m*/ showQueue(); function startAnimation(){ div.animate({height: 300}, "slow"); div.animate({width: 300}, "slow"); div.animate({height: 100}, "slow"); div.animate({width: 100}, "slow",startAnimation); } function showQueue(){ var q = div.queue(); $("span").text(q.length); setTimeout(showQueue); } }); }); </script> </head> <body> <button>Start Animation</button> <p>The queue length is: <span></span></p> <div style="width:50px;height:50px;position:absolute;left:10px;top:100px;background-color:red;"></div> </body> </html>