0

ページの読み込み時に最初に表示される間、すべての DIV の表示を非表示にする必要があります。現時点では、それらはすべて一度に表示され、徐々に消えていき、回転子は最初のサイクルで正常に動作します。

(function($) {

$.fn.testimonialrotator = function(o) {

    var defaults = {
        settings_slideshowTime : '5',
        settings_autoHeight : 'on'
    }

    o = $.extend(defaults, o);
    this.each( function() {
        var cthis = jQuery(this);
        var cchildren = cthis.children();
        var currNr=0;
        var timebuf=0;
        var slideshowTime = parseInt(o.settings_slideshowTime);
        setInterval(tick, 1000);
        cthis.height(cchildren.eq(currNr).height());
        cchildren.eq(0).css('position', 'absolute');
        function tick(){
            timebuf++;
            if(timebuf>slideshowTime){
                timebuf=0;
                gotoNext();
            }
        }
        function gotoNext(){
            var arg=currNr+1;
            if(arg>cchildren.length-1){
            arg=0;
            }
            cchildren.eq(currNr).fadeOut('slow');
            cchildren.eq(arg).fadeIn('slow');
            if(o.settings_autoHeight=='on'){
                cthis.animate({'height' : cchildren.eq(arg).height()})
            }
            currNr=arg;
        }
        return this;
    })
}
})(jQuery)
4

2 に答える 2

1

最も簡単な解決策は、インライン スタイルとして display none を適用することです。

または、script タグで、隠したい要素に display none を適用するだけです: jquery ready ではなく、ロード時に。

于 2013-11-06T22:44:31.757 に答える
1

私はこのようなものを広告します...

$('my_divs').hide();
$('my_divs').first().show();

他のことをする前に、スクリプトに追加してください。

于 2013-11-07T00:36:34.090 に答える