Punctuation loading “animation”, javascript?

后端 未结 8 2340
生来不讨喜
生来不讨喜 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:41

    Now sure how the code got out of hand, you could just do:

    setInterval(function () {
      var span = $("#text-loader").children("span:eq(0)");
      var ellipsis = span.html();
      ellipsis = ellipsis + ".";
      if (ellipsis.length > 5) {
        ellipsis = ".";
      }
      span.html(ellipsis);
    }, 1000);
    
    
    This will display at second 1: "Waiting for your input.

    And as for the 1, you can swap that out with the number of periods.

提交回复
热议问题