jquery “animate” variable value

后端 未结 9 918
说谎
说谎 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条回答
  •  萌比男神i
    2021-02-04 05:58

    try:

    $({someValue: 0}).animate({someValue: 10}, {
        duration: 5000,
        step: function() { 
            $('#el').text(Math.ceil(this.someValue));
        }
    });
    
    

提交回复
热议问题