jquery中stop停止動畫筆記

來源:互聯網
上載者:User

標籤:nbsp   color   tor   osi   lap   包括   按鈕   lib   static   

jQuery stop() 方法用於停止動畫或效果,在它們完成之前。

stop() 方法適用於所有 jQuery 效果函數,包括滑動、淡入淡出和自訂動畫。

文法:

$(selector).stop(stopAll,goToEnd);

可選的 stopAll 參數規定是否應該清除動畫隊列。預設是 false,即僅停止活動的動畫,允許任何排入隊列的動畫向後執行。

可選的 goToEnd 參數規定是否立即完成當前動畫。預設是 false。

因此,預設地,stop() 會清除在被選元素上指定的當前動畫。

其中

stop():表示的是停止當前進行中的動畫,但會執行之後還沒進行的動畫

stop(true):表示的是停止所有的動畫,包括進行中的和還沒有進行的

stop(true,true):表示的是停止所有的動畫,但會將當前進行中的動畫立刻完成

例子如下:

<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script><script> $(document).ready(function(){  $("#start").click(function(){    $("div").animate({left:‘100px‘},5000);    $("div").animate({fontSize:‘3em‘},5000);  });    $("#stop").click(function(){    $("div").stop();  });  $("#stop2").click(function(){    $("div").stop(true);  });  $("#stop3").click(function(){    $("div").stop(true,true);  });  });</script> </head><body><button id="start">開始</button><button id="stop">停止</button><button id="stop2">停止所有</button><button id="stop3">停止動畫,但完成動作</button><p>點擊 "開始" 按鈕開始動畫。</p><p>點擊 "停止" 按鈕停止當前啟用的動畫,但之後我們能再動畫隊列中再次啟用。</p><p>點擊 "停止所有" 按鈕停止當前動畫,並清除動畫隊列,所以元素的所有動畫都會停止。</p><p>點擊 "停止動畫,但完成動作" 快速完成動作,並停止它。</p> <div style="background:#98bf21;height:100px;width:200px;position:absolute;">HELLO</div></body></html>
View Code

 

jquery中stop停止動畫筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.