1

簡単な質問: 無限にループするには、この関数が必要です。試してみましsetTimeoutた(すべてのステップを実行する時間を合計しました)。

<script type="text/javascript">
  $(document).ready(function slideshow(){
    $('#slide1').show(500).delay(500)
      .animate({width:'240px'}).delay(500)
      .animate({height:'50px', width:'410px'}).delay(1500)
      .hide(500)
  });
</script>
4

2 に答える 2

4

試す

jQuery(function($){
    function anim(){
        $('#slide1').show(500).delay(500)
        .animate({width:'240px'}).delay(500)
        .animate({height:'50px', width:'410px'}).delay(1500)
        .hide(500, function(){
            setTimeout(anim, 500)
        })
    }
    anim();
})
于 2013-06-07T05:53:34.613 に答える
0
setInterval(function() {
    $('#myelem').stop().animate({ changes }, 500);
}, 1000);

毎秒、必要なプロパティで要素をアニメーション化します。を使用できますがsetTimeout、ループ用にsetInterval設計されています。どちらでも動作します。

私の答えとの主な違いは、の使用ですstop()。前のアニメーションを停止し、奇妙なダブルアップ バグを防ぎます。

于 2013-06-07T08:42:02.123 に答える