Very short jQuery Image Slideshow

后端 未结 4 1076
我寻月下人不归
我寻月下人不归 2021-01-27 11:47

I\'m looking for the shortest way of creating a fading image slideshow using jQuery. Examples I found on google always had a lot a unneccessary special stuff in it and I had tr

4条回答
  •  迷失自我
    2021-01-27 12:39

    Hope below code may help you,

    var imgArray = ["img1.jpg","img2.jpg","img3.jpg"];
    var i=0;
    setInterval(function(){
        $('div').fadeToggle(2000,function(){
            $(this).text(imgArray[i]);    
        });
        i++;
        if(imgArray.length==i-1){
            i=0;
        }     
    },2000);
    

    Demo

提交回复
热议问题