js slide

Posted mudeng007

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js slide相关的知识,希望对你有一定的参考价值。

$(function () {
    const sliderData=[
        {
            img:"../images/1.jpg",
            name:"",
            desc:"Earth‘s mightiest heroes must come together and learn to fight as a team if they are to stop the mischievous Loki and his alien army from enslaving humanity.",
        },
        {
            img:"../images/2.jpg",
            name:"",
            desc:"Earth‘s mightiest heroes must come together and learn to fight as a team if they are to stop the mischievous Loki and his alien army from enslaving humanity.",
        }
    ];
    for(var i=0;i<sliderData.length;i++){
        var slider=document.querySelector(‘.slider‘);
        var img=sliderData[i].img;
        var name=sliderData[i].name;
        var desc=sliderData[i].desc;
        var slideData=
            // ‘<div class="slide" data-slide="slide-${i}">‘ +
            // ‘   <div class="slide-image"><img src="${img}" ></div>‘ +
            // ‘   <div class="slide-caption">‘ +
            // ‘       <div class="slide-caption-content">‘ +
            // ‘            <div class="title-bg">‘ +
            // ‘               <h1>${name}</h1>‘+
            // ‘               <p>${desc}</p>‘+
            // ‘            </div>‘+
            // ‘       </div>‘+
            // ‘   </div>‘+
            // ‘</div>‘;
            ‘<div class="slide" data-slide="slide-‘+i+‘">‘ +
            ‘   <div class="slide-image"><img src="‘+img+‘" ></div>‘ +
            ‘   <div class="slide-caption">‘ +
            ‘       <div class="slide-caption-content">‘ +
            ‘            <div class="title-bg">‘ +
            ‘               <h1>‘+name+‘</h1>‘+
            ‘               <p>‘+desc+‘</p>‘+
            ‘            </div>‘+
            ‘       </div>‘+
            ‘   </div>‘+
            ‘</div>‘;
        slider.innerhtml += slideData;
    }
    var slides=document.querySelectorAll(".slide");
    var currentSlide=0;
    slides[currentSlide]=0;
    slides[currentSlide].classList.add("visible");
    var slideInterval=setInterval(function () {
        slides[currentSlide].classList.remove("visible");
        currentSlide=(currentSlide+1)%slides.length;
        slides[currentSlide].classList.add("visible");
    },5000);
});

 

以上是关于js slide的主要内容,如果未能解决你的问题,请参考以下文章

轮播slide

一个介绍three.js的不错slide

Ionic 5 angular - 将 ion-slides 迁移到 swiper.js

js slide

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

JQuery UI滑块'slide'功能未设置angularJS值