0

我用 Vegas Slideshow 创建了非常简单的滑块。现在我正在尝试添加简单的 Prev/Next 按钮。这是滑块

    <div class="slide-caption"></div>


    <script src="/assets/js/jquery-3.4.0.min.js"></script>
    <script src="/assets/js/vegas.min.js"></script>
    <script>
        $(".slider-wrapper").vegas({
            slides: [
                { src: "/assets/images/slide-1.jpg", text: "Deployment" },
                { src: "/assets/images/slide-1.jpg", text: "Deployment" },
            ],
            walk: function (index, slideSettings) {
                $('.slide-caption').html(slideSettings.text);
            }
        });
    </script>

这完美地工作。它在下面显示图像和标题。

现在我尝试为按钮添加它,但页面上没有出现任何内容。控制台没有错误。我也不确定是否需要为按钮添加 HTML 或者它是从拉斯维加斯的 JS 和 CSS 中提取的

    <script>
        $(".slider-wrapper").vegas({
            slides: [
                { src: "/assets/images/slide-1.jpg", text: "Deployment" },
                { src: "/assets/images/slide-1.jpg", text: "Deployment" },
            ],
            walk: function (index, slideSettings) {
                $('.slide-caption').html(slideSettings.text);
            }
        });

         // buttons
        $('a#previous').on('click', function () {
        $elmt.vegas('options', 'transition', 'slideRight2').vegas('previous');
        });

        $('a#next').on('click', function () {
            $elmt.vegas('options', 'transition', 'slideLeft2').vegas('next');
        });
    </script>

有人知道我如何添加按钮吗?

4

1 回答 1

1

我还没有测试过这个,但它可能会让你朝着正确的方向前进......

HTML...
<div id="previous" class="button"></div>
<div id="next" class="button"></div>


JQUERY...
    <script>
    $("#previous").click( function() {
$elmt.vegas('options', 'transition', 'slideRight2').vegas('previous');
});

$("#next").click( function() {
$elmt.vegas('options', 'transition', 'slideRight2').vegas('next');
});

</script>       
CSS...
.button {
display: block;
height: 100px;
width: 100px;
background-color: purple;
 }
于 2019-04-30T15:15:39.697 回答