Punctuation loading “animation”, javascript?

后端 未结 8 2315
生来不讨喜
生来不讨喜 2021-02-19 17:54

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         


        
8条回答
  •  北海茫月
    2021-02-19 18:33

    Here is a modified version that will turn off the dots after a time.

    var count = 0;
    var dots = setInterval(function(){
      count++;
      document.getElementById('loadingtext').innerHTML = "Waiting for your input." + new Array(count % 5).join('.');
    
      if (count == 10){ // show two iterations of the array.
        clearInterval(dots); // stop the dots.
      }
    }, 100); // sets the speed
    

    http://jsfiddle.net/Ty4gt/331/

提交回复
热议问题