關於jquery內建動畫效果的stop()問題

來源:互聯網
上載者:User

標籤:

首先先來看一下jquery中stop()的用法

  • stop()用於在動畫執行前停止正在執行的動畫
  • stop(stopAll,goToEnd)的兩個參數為布爾值;
  • stopAll:true/false;是否停止對象接下來所有的動畫;
  • goToEnd:true/false;停止方式是直接將動畫播放至結束位置還是停止在當前位置。

jquery中的fadeIn、fadeOut,slideDown、slideUp如果設定stop(false,false),動畫停止的位置將被記錄下來,下一次動畫走到上次被停止的位置就會結束。而我們需要的是下一次動畫依舊能夠完整執行,所以需要設定stop(true,true),將動畫直接播放至結束。

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Document</title>    <script src="//cdn.bootcss.com/jquery/3.1.0/jquery.min.js"></script>    <style type="text/css">        .wodejifen_box{            position:relative;            width:80px;            height:34px;            overflow: visible;        }        .wodejifen{            height:34px;            font-size: 12px;            width:80px;            line-height: 34px;            border:1px solid red ;            text-align: center;        }        .wodejifen_content{            position:absolute;            width:150px;            top:34px;            left:0;            border:1px solid black;            padding:5px;            display:none;        }        .wodejifen_content li{            border-bottom:1px solid black;            line-height:20px;            list-style: none;            padding:0;        }    </style></head><body><div class="wodejifen_box">    <div class="wodejifen">        我的積分        </div>    <ul class="wodejifen_content">            <li>內容0000000</li>            <li>內容1111111</li>            <li>內容2222222</li>            <li>內容3333333</li>    </ul></div>        <script type="text/javascript">        $(‘.wodejifen‘).mouseover(function(event){            $(‘.wodejifen_content‘).stop(true,true).slideDown(150);        }).mouseout(function(event){            $(‘.wodejifen_content‘).stop(true,true).slideUp(150);        });    </script></body></html>

 

關於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.