jquery “animate” variable value

后端 未结 9 930
说谎
说谎 2021-02-04 05:36

I need to \"animate\" a variable with jquery.

Example: The variable value is 1. The value should be 10 after 5 seconds. It should be increase \"smoothl

9条回答
  •  再見小時候
    2021-02-04 06:02

    This should work for you:

    var a = 1;
    var b = setInterval(function() {
      console.log(a);
      a++;
      if (a == 10) { clearInterval(b); }
    }, 500);
    

提交回复
热议问题