-1

1 つの Web サイト用にシンプルな jquery バナーをデザインしました。バナーは正常に機能していますが、設定された間隔でバナーを自動更新する方法。さまざまなコードを実行しましたが、機能していません。特定の間隔でバナーのコードの繰り返しを修正してください。

CSS コード:

 .banner {-webkit-border-radius:6px;    -moz-border-radius:8px;    
              border-radius:8px; -khtml-border-radius: 8px; 
              border:#bbd9ef solid 1px; background:#f5fffa; 
              padding: 5px 0 0 20px; width: 200px; height: 110px; 
             }
  .k, .l, .m, .n {position: relative; top: -200px; text-decoration: none; }
  .n { font-weight: bold; color: red; }

jquery1.9.1 のスクリプト コード:

$(document).ready(function() {
    $(".banner a").hide();
    (function() {
        $(".k").show().animate({
            top: "0"
        }, 3000, function() {
            $(".l").show().animate({
                top: "0"
            }, 3000, function() {
                $(".m").show().animate({
                    top: "0"
                }, 3000, function() {
                    $(".n").show().animate({
                        top: "0"
                    }, 3000);
                });
            });
        });
    })();
});

HTML コード:

<div class="banner">
    <a href="#" class="k">Design banner in your ownway</a><br />
    <a href="#" class="l"> Get more taffic and publishers.</a><br/>
    <a href="#" class="m">Still doubt, please do contact:</a><br/><br/>
    <a href="#" class="n">www.freemenu.info</a>
</div>
4

1 に答える 1

0

要素nが表示されたら、タイマーを設定してアニメーションを再開します

$(document).ready(function () {
    $(".banner a").hide();
    function banner(){
        $(".k").show().animate({
            top: "0"
        }, 3000, function () {
            $(".l").show().animate({
                top: "0"
            }, 3000, function () {
                $(".m").show().animate({
                    top: "0"
                }, 3000, function () {
                    $(".n").show().animate({
                        top: "0"
                    }, 3000, function(){
                        setTimeout(function(){
                            $(".banner a").hide().css('top', '');
                            banner();
                        }, 5000);
                    });
                });
            });
        });
    }
    banner();
});

デモ:フィドル

于 2013-09-22T12:24:17.207 に答える