ホームページ  >  記事  >  ウェブフロントエンド  >  jquery late() の紹介と使用ガイド

jquery late() の紹介と使用ガイド

巴扎黑
巴扎黑オリジナル
2017-06-30 13:13:392132ブラウズ

.lay() は、jQuery アニメーション効果や同様のキューで使用するのが最適です。ただし、遅延をキャンセルできない - .lay() などの独自の制限があるため、特定のユースケースにより適している可能性がある JavaScript のネイティブ setTimeout 関数の代替ではありません。

delay(duration,[queueName])

キュー内の後続のアイテムの実行を遅らせる遅延を設定します。
jQuery 1.4新機能。キュー内の関数の実行を遅らせるために使用されます。アニメーション キューの実行を遅らせることも、カスタム キューで使用することもできます。

duration: 遅延時間、単位: ミリ秒

queueName: キュー名詞、デフォルトは Fx、アニメーションキューです。

パラメータ 説明
速度 オプション。ディレイの速さを指定します。

可能な値:

  • ms

  • 「遅い」

  • 「速い」

queueName オプション。キューの名前を指定します。

デフォルトは「fx」、標準のエフェクトキューです。


$("button").click(function(){
$("#p1").delay("slow").fadeIn();
$("#p2").delay("fast").fadeIn();
});

完全なテストコード:


<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
 $("button").click(function(){
  $("#p1").delay("slow").fadeIn();
  $("#p2").delay("fast").fadeIn();
  $("#p3").delay(800).fadeIn();
  $("#p4").delay(2000).fadeIn();
  $("#p5").delay(4000).fadeIn();
 });
});
</script>
</head>

<body>
<p>This example sets different speed values for the delay() method.</p>
<button>Click to fade in boxes with a delay</button>
<br><br>
<p id="p1" style="width:90px;height:90px;display:none;background-color:black;"></p><br>
<p id="p2" style="width:90px;height:90px;display:none;background-color:green;"></p><br>
<p id="p3" style="width:90px;height:90px;display:none;background-color:blue;"></p><br>
<p id="p4" style="width:90px;height:90px;display:none;background-color:red;"></p><br>
<p id="p5" style="width:90px;height:90px;display:none;background-color:purple;"></p><br>
</body>
</html>

例:

頭と底部の遅延読み込みアニメーション効果


$(document).ready(function() {
 $(&#39;#header&#39;)
 .css({ &#39;top&#39;:-50 })
 .delay(1000)
 .animate({&#39;top&#39;: 0}, 800);

 $(&#39;#footer&#39;)
 .css({ &#39;bottom&#39;:-15 })
 .delay(1000)
 .animate({&#39;bottom&#39;: 0}, 800); 
});

以上がjquery late() の紹介と使用ガイドの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。