如何让这个滑块自动播放?

时间:2013-10-10 19:28:21

标签: slider project autoplay

我正在开展一个项目,我正在与这个问题作斗争。

我想将此滑块设为自动播放

<script type="text/javascript">
    $(document).ready(function () {

        var showCaseItems = $('.show-case-item').hide();

        var splashes = $('.splash').hide();
        //get each image for each slide and set it as a background of the slide
        //            splashes.each(function () {
        //                var img = $(this).find('img');
        //                var imgSrc = img.attr('src');
        //                img.css('visibility', 'hidden');
        //                $(this).css({ 'background-image': 'url(' + imgSrc + ')', 'background-repeat': 'no-repeat' });
        //            });

        splashes.eq(0).show();
        showCaseItems.eq(0).show();

        var prevIndex = -1;
        var nextIndex = 0;
        var currentIndex = 0;

        $('#banner-pagination li a').click(function () {

            nextIndex = parseInt($(this).attr('rel'));

            if (nextIndex != currentIndex) {
                $('#banner-pagination li a').html('<img src="<?php bloginfo('template_url'); ?>/assets/img/slidedot.png" alt="slide"/>');
                $(this).html('<img src="<?php bloginfo('template_url'); ?>/assets/img/slidedot-active.png" alt="slide"/>');
                currentIndex = nextIndex;
                if (prevIndex < 0) prevIndex = 0;

                splashes.eq(prevIndex).css({ opacity: 1 }).animate({ opacity: 0 }, 500, function () {
                    $(this).hide();
                });
                splashes.eq(nextIndex).show().css({ opacity: 0 }).animate({ opacity: 1 }, 500, function () { });

                showCaseItems.eq(prevIndex).css({ opacity: 1 }).animate({ opacity: 0 }, 500, function () {
                    $(this).hide();
                    showCaseItems.eq(nextIndex).show().css({ opacity: 0 }).animate({ opacity: 1 }, 200, function () { });
                });

                prevIndex = nextIndex;
            }

setTimeout(function(){$('#banner-pagination li a')。trigger('click');},1500); &lt; - 这个dindt使它成为autplay onload,但在“点击”之后

            return false;
        });

    });
</script>

1 个答案:

答案 0 :(得分:0)

这是哪个滑块?我看到你正在调用触发器,触发器在哪里?它做了什么?