javascript using settimeout() with a loop

后端 未结 4 1610
醉酒成梦
醉酒成梦 2021-01-24 20:21

ive got a table with 8x10 cells.. each sell got an input element with its own id (11, 12, ... , 21,22,23,...) now i want to fill these inputs after and after (lets say 0.5 sec)

4条回答
  •  不思量自难忘°
    2021-01-24 20:43

    You can try something like this:

        var i = 1;
        var k = 1;
        var obj = setInterval( function () {
            document.getElementById(i + '' + k).value= Betrag[i][k];
            if(k <= 10)
               k++;
            else
            {
                k = 1;
                if(i<=8)
                     i++;
                else
                     clearInterval(obj);
            }
        }, 1000);
    

    Here's a running example at http://jsfiddle.net/Ex98V/

提交回复
热议问题