Punctuation loading “animation”, javascript?

后端 未结 4 1432
甜味超标
甜味超标 2021-02-19 17:52

I\'m looking for a good way to display some punctuation loading \"animation\".

What I want is something like this:

This will display at second 1: \"Waiti         


        
4条回答
  •  感动是毒
    2021-02-19 18:26

    The trick to making a string of dots is to make a sparse Array and then join all the elements with the desired character.

    var count = 0;
    setInterval(function(){
        count++;
        var dots = new Array(count % 10).join('.');
        document.getElementById('loadingtext').innerHTML = "Waiting for your input." + dots;
      }, 1000);
    

    Here is a Live demo.

提交回复
热议问题