Dot dotdot dotdotdot as loading?

2020-05-16 15:28发布

I wanna create some loading dots, like this:

At 0000 miliseconds the span content is: .

At 0100 miliseconds the span content is: ..

At 0200 miliseconds the span content is: ...

In a loop.

What is the best / easiest way to make it?

7条回答
贪生不怕死
2楼-- · 2020-05-16 16:01
let span = document.querySelector('span');
    i = 0;

setInterval(() => {
    span.innerText = Array(i = i > 2 ? 0 : i + 1).fill('.').join('');
}, 500)
查看更多
登录 后发表回答