Home > Web Front-end > JS Tutorial > jQuery clearQueue related introduction and examples

jQuery clearQueue related introduction and examples

巴扎黑
Release: 2017-06-20 15:06:09
Original
1264 people have browsed it

The clearQueue() method is combined with the clearQueue() method;

.clearQueue() can be used to remove any function added to a generic jQuery sequence via the .queue() method .

Example:


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

  <script type="text/javascript" src="/jquery/jquery.js"></script>
</head>

<body>

<button id="start">开始</button>
<button id="stop">停止</button>
<p></p>

<script>
$("#start").click(function () {
  $("p").show("slow");
  $("p").animate({left:&#39;+=200&#39;},5000);
  $("p").queue(function () {
    $(this).addClass("newcolor");
    $(this).dequeue();
  });
  $("p").animate({left:&#39;-=200&#39;},1500);
  $("p").queue(function () {
    $(this).removeClass("newcolor");
    $(this).dequeue();
  });
  $("p").slideUp();
});
$("#stop").click(function () {
  $("p").clearQueue();
  $("p").stop();
});
</script>


</body>
</html>
Copy after login

The above is the detailed content of jQuery clearQueue related introduction and examples. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template