返回值:jQuerystop([clearQueue],[jumpToEnd])
jQuery stop() 方法概述
停止所有在指定元素上正在運行的動(dòng)畫(huà)。
如果隊列中有等待執行的動(dòng)畫(huà)(并且clearQueue沒(méi)有設為true),他們將被馬上執行
參數
[clearQueue],[gotoEnd]Boolean,BooleanV1.2
clearQueue:如果設置成true,則清空隊列??梢粤⒓唇Y束動(dòng)畫(huà)。
gotoEnd:讓當前正在執行的動(dòng)畫(huà)立即完成,并且重設show和hide的原始樣式,調用回調函數等。
[queue],[clearQueue],[jumpToEnd]BooleanV1.7
queue:用來(lái)停止動(dòng)畫(huà)的隊列名稱(chēng)
clearQueue:如果設置成true,則清空隊列??梢粤⒓唇Y束動(dòng)畫(huà)。
jumpToEnd:如果設置成true,則完成隊列??梢粤⒓赐瓿蓜?dòng)畫(huà)。
示例
描述:
停止當前正在運行的動(dòng)畫(huà):
HTML 代碼:
$("#stop").click(function(){
$("#box").stop();
});
描述:
點(diǎn)擊Go之后開(kāi)始動(dòng)畫(huà),點(diǎn)Stop之后會(huì )在當前位置停下來(lái)
HTML 代碼:
<button id="go">Go</button> <button id="stop">STOP!</button>
<div class="block"></div><button id="go">Go</button> <button id="stop">STOP!</button>
<div class="block"></div>
jQuery 代碼:
// 開(kāi)始動(dòng)畫(huà)
$("#go").click(function(){
$(".block").animate({left: '+200px'}, 5000);
});
// 當點(diǎn)擊按鈕后停止動(dòng)畫(huà)
$("#stop").click(function(){
$(".block").stop();
});