jquery queue() method


  Translation results:

queue

英[kju:] 美[kju]

n. (people or vehicles) queue, long queue; braid

vi. (people, cars, etc.) line up and wait

vt. (make) line up, line up and wait

jquery queue() methodsyntax

Function: queue() method displays or operates the function queue executed on the matching element.

Syntax: .queue(queueName)

Parameters: queueName Optional. String value containing the name of the sequence. The default is fx, the standard effects sequence.​

Operation queue: queue() method operates the function queue executed on the matching element.

Syntax: .queue(queueName,newQueue)

##Parameters: queueName Optional. String value containing the name of the sequence. The default is fx, the standard effects sequence.

Note: Each element can have one or more function queues added by jQuery. In most applications, only one queue (named fx) is used. Queue runs asynchronously invoke sequences of actions on elements without terminating program execution. A typical example is calling multiple animation methods on an element.

jquery queue() methodexample

<!DOCTYPE html>
<html>
<head>
  <style>div { margin:3px; width:40px; height:40px;
        position:absolute; left:0px; top:60px; 
        background:green; display:none; }
  div.newcolor { background:blue; }
  p { color:red; }  </style>

  <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
</head>

<body>

<p>队列长度是:<span></span></p>
<div></div>

<script>
var div = $("div");

function runIt() {
  div.show("slow");
  div.animate({left:'+=200'},2000);
  div.slideToggle(1000);
  div.slideToggle("fast");
  div.animate({left:'-=200'},1500);
  div.hide("slow");
  div.show(1200);
  div.slideUp("normal", runIt);
}

function showIt() {
  var n = div.queue("fx");
  $("span").text( n.length );      
  setTimeout(showIt, 100);
}

runIt();
showIt();
</script>

</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A