i am trying to use the following code to increment number in a textbox
// Animate the element's value from 0 to 1100000:
$({someValue: 0}).animate({someValue: 1100000}, {
duration: 1000,
step: function() { // called on every step
// Update the element's text with value:
$('#counterx').text(Math.floor(this.someValue+1));
}
});
it is working with small numbers like from 0 to 100 but when it comes to large number like in the mentioned code, it is not giving the target number, it is animating to numbers like 1099933 or 1099610 or ..... and every time it changes.
so how can i make it to animate to the number i specify?
someValue
? is this a valid css property? post you markup..animate()
is best for animating CSS properties. If you want to "animate" the text inside a div, you need to create a function that loops and changes.text()
at each iteration.complete
event.