這篇文章主要介紹了jQuery中clearQueue()方法用法,實例分析了clearQueue()方法的功能、定義及進行清空隊列操作的技巧,具有一定的參考借鑒價值,需要的朋友可以參考下
本文實例講述了jQuery中clearQueue()方法用法。分享給大家供大家參考。具體分析如下:
此方法能夠清空對象上尚未執(zhí)行的所有隊列。
如果不帶參數(shù),則默認清空的是動畫隊列。這跟stop(true)類似,但stop()只能清空動畫隊列,而這個可以清空所有通過queue()創(chuàng)建的隊列。
語法結(jié)構(gòu):
復(fù)制代碼代碼如下:
$(selector).clearQueue(queueName)
參數(shù)列表:
| 參數(shù) | 描述 |
| queueName | 可選。定義要停止的隊列的名稱。 默認是 "fx",動畫隊列。 |
實例代碼:
復(fù)制代碼代碼如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://m.survivalescaperooms.com/" />
<title>武林網(wǎng)</title>
<style type="text/css">
#father
{
background:#060;
width:300px;
height:300px;
}
#box
{
background:red;
height:50px;
width:50px;
position:relative
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#start").click(function(){
$("#box").animate({height:200},"slow");
$("#box").animate({width:200},"slow");
$("#box").animate({height:50},"slow");
$("#box").animate({width:50},"slow");
});
$("#clear").click(function(){
$("#box").clearQueue();
});
});
</script>
</head>
<body>
<p>
<button id="start">開始執(zhí)行動畫</button>
<button id="clear">清除隊列</button>
</p>
<div id="father">
<div id="box"></div>
</div>
</body>
</html>
希望本文所述對大家的jquery程序設(shè)計有所幫助。