What does this paragraph mean?

var imgs = ["1.jpgrecords," 2.jpgrecords recorder 3.jpg"];

var idx = 0;

function resetImgs(dir){
    var len = imgs.length;

    switch(dir){
        case "PREV":
            if(idx <= 0){
                idx = len - 1;
                  _setPrevImgs(idx);
            }else{
                idx--;
                _setPrevImgs(idx);
            }
              break;
        case "NEXT":
            if(idx >= 0 && idx < len - 1){
                _setNextImgs(idx);
                idxPP;
            }else if(idx >= len - 1){
                _setNextImgs(idx);
                idx = 0;
            }
        break;
    }

    for(var i in imgs){
        document.getElementById("img" + (Number(i) + 1)).src = imgs[i];
    }

    function _setNextImgs(index){
        curImg = (index + 1) + ".jpg";
        imgs.splice(0, 1);
        imgs.push(curImg);
    }

    function _setPrevImgs(index){
        curImg = (index + 1) + ".jpg";
        imgs.splice(len - 1, 1);
        imgs.unshift(curImg);
Mar.02,2021

defines an array that holds the src information of the picture.

var imgs = ['1.jpg', '2.jpg','3.jpg'];

when calling the resetImgs function, the parameter dir is used to determine whether it is the previous picture or the next picture.
if it is the previous picture, execute _ setPrevImgs
if it is the next picture, execute _ setNextImgs
these two functions to modify curImg and change the value of curImg, that is, the current picture.

if you don't understand, you can continue to ask ~

Menu