jquery基本用法

來源:互聯網
上載者:User
函數 描述
$(selector).hide() 隱藏被選元素
$(selector).show() 顯示被選元素
$(selector).toggle() 切換(在隱藏與顯示之間)被選元素
$(selector).slideDown() 向下滑動(顯示)被選元素
$(selector).slideUp() 向上滑動(隱藏)被選元素
$(selector).slideToggle() 對被選元素切換向上滑動和向下滑動
$(selector).fadeIn() 淡入被選元素
$(selector).fadeOut() 淡出被選元素
$(selector).fadeTo() 把被選元素淡出為給定的不透明度
$(selector).animate() 對被選元素執行自訂動畫

 

 

jQuery 函數建立自訂動畫的文法:

$(selector).animate({params},[duration],[easing],[callback])

關鍵的參數是 params。它定義產生動畫的 CSS 屬性。可以同時設定多個此類屬性:

animate({width:"70%",opacity:0.4,marginLeft:"0.6in",fontSize:"3em"});

第二個參數是 duration。它定義用來應用到動畫的時間。它設定的值是:"slow", "fast", "normal" 或毫秒。

執行個體 1
<script type="text/javascript">$(document).ready(function(){$("#start").click(function(){$("#box").animate({height:300},"slow");$("#box").animate({width:300},"slow");$("#box").animate({height:100},"slow");$("#box").animate({width:100},"slow");});});</script> 
 
函數 描述
$(selector).html(content) 改變被選元素的(內部)HTML
$(selector).append(content) 向被選元素的(內部)HTML 追加內容
$(selector).prepend(content) 向被選元素的(內部)HTML “預置”(Prepend)內容
$(selector).after(content) 在被選元素之後添加 HTML
$(selector).before(content) 在被選元素之前添加 HTML

 

聯繫我們

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