您好,欢迎来到豪车资讯网。
搜索
您的当前位置:首页jQueryclearQueue相关介绍及实例讲解

jQueryclearQueue相关介绍及实例讲解

来源:豪车资讯网


clearQueue()方法与clearQueue()方法结合;

.clearQueue()可用于删除通过.queue()方法添加到通用jQuery序列的任何函数。

示例:


<!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:'+=200'},5000);
 $("p").queue(function () {
 $(this).addClass("newcolor");
 $(this).dequeue();
 });
 $("p").animate({left:'-=200'},1500);
 $("p").queue(function () {
 $(this).removeClass("newcolor");
 $(this).dequeue();
 });
 $("p").slideUp();
});
$("#stop").click(function () {
 $("p").clearQueue();
 $("p").stop();
});
</script>


</body>
</html>

Copyright © 2019- how1234.com.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务