Loading encountered a problem, how to end the loading, can jump out of the function do not run the code?

clipboard.png

my code structure is like this
I think after on load, besides fadeOut, the js function on
also stops and stop running.
how can this be written?

Update

$(document).ready(function () {
    $(".pageloading").show();

    var curIndex=0;
    var timeInterval=90;

    var arr = new Array();
    arr[0]="images/ja/XY0001.png";
    arr[1]="images/ja/XY0002.png";
    arr[2]="images/ja/XY0003.png";
    arr[3]="images/ja/XY0004.png";
    arr[4]="images/ja/XY0005.png";
    arr[5]="images/ja/XY0006.png";
    arr[6]="images/ja/XY0007.png";
    arr[7]="images/ja/XY0008.png";

    var timer = setInterval(changeImg,timeInterval);
    function changeImg(){
      var obj=document.getElementById("obj");
      if(curIndex==arr.length-1){
        curIndex=0;
      }else{
        curIndex+=1;
      }
      obj.src=arr[curIndex];

      return changeImg();
    }
});

$(window).on("load", function(){
    $(".pageloading").fadeOut();

    window.clearInterval(timer);
});

do I have the right code
or am I weird
and he doesn"t seem to be running in sequence?


emmmm, should be minimized, with as few changes as possible. The changes are as follows:

var intervalTimer;
$(document).ready(function () {
    $(".pageloading").show();

    var curIndex=0;
    var timeInterval=90;

    var arr = new Array();
    arr[0]="images/ja/XY0001.png";
    arr[1]="images/ja/XY0002.png";
    arr[2]="images/ja/XY0003.png";
    arr[3]="images/ja/XY0004.png";
    arr[4]="images/ja/XY0005.png";
    arr[5]="images/ja/XY0006.png";
    arr[6]="images/ja/XY0007.png";
    arr[7]="images/ja/XY0008.png";

    intervalTimer = setInterval(changeImg,timeInterval);
    function changeImg(){
      var obj=document.getElementById("obj");
      if(curIndex==arr.length-1){
        curIndex=0;
      }else{
        curIndex+=1;
      }
      obj.src=arr[curIndex];
    }
});

$(window).on('load', function(){
    $(".pageloading").fadeOut();
    clearInterval(intervalTimer);
});

at the time var timer = setInterval (changeImg,timeInterval);

window.clearInterval (timer); after on load

(note that timer should be a global variable, otherwise this variable will not be married in onload)

(add:) try this
clipboard.png

Menu