jquery筆記(效果)

來源:互聯網
上載者:User

標籤:

顯示/隱藏:

$(selector).hide(speed, function()):隱藏

$(selector).show(speed, function()):隱藏

$(selector).toggle(speed, function()):顯示/隱藏切換

淡入/淡出:

$(selector).fadeIn(speed, function()):淡入,必須先把元素隱藏掉(display:none)

$(selector).fadeOut(speed, function()):淡出,即慢慢的隱藏掉

$(selector).fadeToggle(speed, function()):淡入/淡出切換

$(selector).fadeTo(speed,opacity,function());:方法允許漸層為給定的不透明度(值介於 0 與 1 之間)

滑動:

$(selector).slideDown(speed,function()):向下滑動

$(selector).slideUp(speed,function()):向上滑動

$(selector).slideToggle(speed,function()):切換

動畫:

$(selector).animate({params},speed,function()):當使用 animate() 時,必須使用 Camel 標記法書寫所有的屬性名稱,比如,必須使用 paddingLeft 而不是 padding-left,使用 marginRight 而不是 margin-right,等等。同時,色彩動畫並不包含在核心 jQuery 庫中。與css3動畫略有不同的是個人覺得比較好控制,不會回到原來的狀態。

  可以取相對值:

$("button").click(function(){
  $("div").animate({
    left:‘250px‘,
    height:‘+=150px‘,
    width:‘+=150px‘
  });
}); 

使用預定義值:hide(),show(),toggle()

$("button").click(function(){
  $("div").animate({
    height:‘toggle‘
  });
}); 

使用隊列:

$("button").click(function(){
  var div=$("div");
  div.animate({height:‘300px‘,opacity:‘0.4‘},"slow");
  div.animate({width:‘300px‘,opacity:‘0.8‘},"slow");
  div.animate({height:‘100px‘,opacity:‘0.4‘},"slow");
  div.animate({width:‘100px‘,opacity:‘0.8‘},"slow");
}); 

停止動畫:

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

$(selector).stop(stopAll,goToEnd):可選的 stopAll 參數規定是否應該清除動畫隊列。預設是 false,即僅停止活動的動畫,允許任何排入隊列的動畫向後執行。可選的 goToEnd 參數規定是否立即完成當前動畫。預設是 false。因此,預設地,stop() 會清除在被選元素上指定的當前動畫。 方法連結:$("#p1").css("color","red").slideUp(2000).slideDown(2000);

jquery筆記(效果)

聯繫我們

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