Jquery 如何编写自动幻灯片放映循环?

Jquery 如何编写自动幻灯片放映循环?,jquery,Jquery,我想在幻灯片中添加一个循环,但我对jQuery还不熟悉,不知道怎么做。以下是代码: $(function(){ $("#slide_container").mouseout(function(){ /*a loop here that change the images automatically when the mouse is not inside the div, get the index of the image and add to it

我想在幻灯片中添加一个循环,但我对jQuery还不熟悉,不知道怎么做。以下是代码:

$(function(){
    $("#slide_container").mouseout(function(){

        /*a loop here that change the images automatically when the mouse is not inside the div,
        get the index of the image and add to it like a for loop (i = 0; i < slides.length; i++) 
        but I still don't know which var should I add and how mouseout works.*/

    });

    $("#slide_container").mouseover(function(){
        $('#nextBtn').on('click', function(){
            console.log('clicked');
            var currentImg = $(".active");
            var nextImg = currentImg.next();

            if(nextImg.length){
                currentImg.removeClass('active').css('z-index', -10);
                nextImg.addClass('active').css('z-index', 10);
            }

        });

        $('#prevBtn').on('click', function(){
            console.log('clicked');
            var currentImg = $(".active");
            var prevImg = currentImg.prev();
            if(prevImg.length){
                currentImg.removeClass('active').css('z-index', -10);
                prevImg.addClass('active').css('z-index', 10);
            }

        })
$(函数(){
$(“#滑动容器”).mouseout(函数(){
/*这里有一个循环,当鼠标不在div内时自动更改图像,
获取图像的索引并像for循环一样添加到其中(i=0;i
如果在惯性间隔内连续编码,则可以使用

您可以触发按钮上的单击以向前滑动

设s_interval=null;
每次转换之间的常数延迟=1000//1s
$(“#滑动容器”).mouseout(函数(){
const next_按钮=$(“#nextBtn”)
s_interval=setInterval(()=>next_按钮。单击(),延迟)
});
$(“#幻灯片_容器”).mouseenter(函数(){
清除间隔(s_间隔)
});

非常感谢。关于第二部分。mouseenter,我应该怎么写?只是。很抱歉,我不明白你所说的“我应该怎么写”是什么意思,以及我如何编写它,使它返回到第一个图像,就像一个循环。很抱歉,我对编程非常陌生。