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

jQuery clearQueue related introduction and examples

巴扎黑
巴扎黑Original
2017-06-20 15:06:091281browse

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>

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!

Statement:
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