jQuery text loading animation

后端 未结 5 1175
隐瞒了意图╮
隐瞒了意图╮ 2021-01-05 01:22

Trying to make a text ... loading animation

here\'s where I stand: http://jsfiddle.net/aGfct/

I can get the ... to be added at 500 ms intervals, but then I w

5条回答
  •  逝去的感伤
    2021-01-05 02:08

    i = 0;
    setInterval(function() {
        i = ++i % 4;
        $("#loading").html("loading"+Array(i+1).join("."));
    }, 500);
    

    If you wish to change the string after 5 says, that's after 10 iterations. This can be accomplished like this.

    i = 0;
    text = "loading";
    setInterval(function() {
        $("#loading").html(text+Array((++i % 4)+1).join("."));
        if (i===10) text = "start";
    }, 500);
    

提交回复
热议问题