Jquery效果-animate,toggle

來源:互聯網
上載者:User

animate() 方法執行 CSS 屬性集的自訂動畫。

文法:$("divImg").animate(styles,speed,easing,callback)

參數:styles 必填,規定產生動畫效果的 CSS 樣式和值

        speed 可選,規定動畫產生速度,預設normal,還有fast ,slow,毫秒值

      easing 可選,不同的動畫點種設定速度(很少使用)

     callback可選,animate函數之後執行的函數

toggle() 方法切換元素的可見狀態。

文法:$(selector).toggle(speed,callback,switch)

參數:三個參數都是可選的,

switch:布爾值。規定 toggle 是否隱藏或顯示所有被選元素。true、false,如果設定此參數,則無法使用 speed和 callback 參數。

執行個體:

View Code

 1 <script type="text/javascript">
2 // 收縮展開效果
3 $(document).ready(function () {
4 $(".information_title").toggle(function () {
5 $(this).next(".information_contant").animate({ height: 'toggle', opacity: 'toggle' }, "slow");
6 }, function () {
7 $(this).next(".information_contant").animate({ height: 'toggle', opacity: 'toggle' }, "slow");
8 });
9 });
10 </script>
11
12 <div class="information_title">
13
14
15 </div>
16
17 <div class="information_contant">
18
19 </div>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.