JQuery的stop()屬性

來源:互聯網
上載者:User

標籤:style   blog   io   ar   color   os   sp   on   div   

    $(function(){        $(‘#input1‘).hover(            function(){            $(‘.div1‘).stop()                      .animate({left:"+=50px"},1000)                      .animate({top:"+=40px"},2000);            }            ,function(){            $(‘.div1‘).stop()                      .animate({width:"+=50px"},2000)                      .animate({height:"+=40px"},1000)            }        )    })

CSS 部分

.div1{        width:300px;        height:300px;        border:1px solid #ccc;        background: #666;        position:absolute;        left:30%;        top:30%;        margin-left:-150px;        margin-top:-150px;    }

html部分

<div class="div1"></div><br/><input type="button" id="input1" value="開始動畫" />

測試結果:

 1.執行left時,移除滑鼠,發生第二個stop(),阻止left,執行top、width和height;
 2.執行top時,移除滑鼠,發生第二個stop(),阻止top, 執行width 和 height;
 3.執行left時,移除滑鼠,當未執行完top時,移入,發生第一個stop(),阻止top,按照順序執行width和height,以及新的left和top;
 4.執行top時,移除滑鼠,當未執行完width時,移入,發生第一個stop(),阻止width,按順序執行height,以及新的left和top;

結論:

stop() 只能阻止上一個動畫

 

stop()參數測試

預設的stop(),即為stop( false , false )

在JQuery 代碼中相應位置填入,則

====> stop(true,false) 阻止一個隊列中(function(){ ... })的動畫
====> stop(false,true) 僅組織一個動畫(類似與stop()),跳到上一個動畫結束狀態
====> stop(true,true)  阻止一個隊列中的動畫,並跳到隊列末尾動畫狀態

 

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.