Basic jQuery animation: Elipsis (three dots sequentially appearing)

后端 未结 4 2059
余生分开走
余生分开走 2021-02-04 17:24

What I need:

I need an animated elipisis (...), one dot appearing after the other. The animation needs to loop. I\'d like to achieve this via jQuery

Animation

4条回答
  •  长发绾君心
    2021-02-04 17:49

    If you just need the dots to appear one after another only once, try something very simple like the following:

    Awaiting your selection
    ​ var dots = 0; $(document).ready(function() { setInterval (type, 600); }); function type() { if(dots < 3) { $('#message').append('.'); dots++; } }​

    http://jsfiddle.net/fVACg/

    If you want them to appear more than once (to be deleted and then re-printed), you can do something like the following:

    Awaiting your selection
    ​ var dots = 0; $(document).ready(function() { setInterval (type, 600); }); function type() { if(dots < 3) { $('#dots').append('.'); dots++; } else { $('#dots').html(''); dots = 0; } }​

    http://jsfiddle.net/wdVh8/

    Finally, checkout a tutorial I've written a few years ago. You might find it useful.

提交回复
热议问题