I have a basic counter that counts up within an input field. this works exactly how I want it to. The problem I am facing is that I can only set the target number via the input value. i want to be able to set this via a js variable, ignoring the html input value
DEMO http://jsfiddle.net/vyN6V/238/
Current jQuery
var number = 827;
function count(Item){
var current = parseInt(Item.val());
Item.val(current +=5);
if(current < number){
setTimeout(function(){count(Item)}, 0.1);
}
}
count($(".input"));
Desired jQuery (doesn't work)
var number = 827;
var aValue = 500;
function count(Item){
var current = aValue;
Item.val(current +=5);
if(current < number){
setTimeout(function(){count(Item)}, 0.1);
}
}
count($(".input"));