我试图做一个数值,比如5000,快速切换到另一个价值,说4000,使用JQuery。现在我做使用这个罚款:使用JQuery生成动画数字(半倒数)?
mod(".class",4000,"add");
function mod(id,value,type){
var numb = $(id).html();
var current_value = parseInt(numb);
do {
if(type == "add")
increment(id);
else
decrement(id);
current_value = parseInt(numb);
}while(current_value != value);
function decrement(id){
$(id).html(current_value-1);
}
function increment(id){
$(id).html(current_value+1);
}
}
我知道这可能不是去它的最好办法,但我需要它做的是倒计时(或以上)的人数很快从目前的值设定值。我用这种方法的目的是延迟使用setInterval或setTimeout,但是这会使整个脚本失败。
任何建议表示赞赏,但我宁愿不使用大量插件这个看似简单的任务。
它看起来像你的目标是提供一个可见的倒计时或显示器。抛开代码效率,您提供的代码看起来很实用。你有什么问题? – keithm
恩,应该是“你的” – keithm