实现数字变化的效果
我有一个这样的计数器:
<ul>
<li id="cenMill">0</li>
<li id="decMill">0</li>
<li id="uniMill">0</li>
<li id="cen">3</li>
<li id="dec">2</li>
<li id="uni">1</li>
</ul>
- 0 0 0 3 2 1
我的目的是让每个数字根据我给它的变量进行更改,也就是说,如果我添加+1,那么只需将 id="uni" 从 1 更改为 2,但如果我给它 12 那么更改受影响的两者等等。然而,到目前为止,我不知道如何开始执行此操作,这就是我所拥有的:
$('#uni').animate({
marginTop: "-25px",
},200);
但这只会将 1 放在顶部,它不会从下面弹出“2”作为下一个数字,而 1 是可见,即使使用显示、“无”或其他类似的方式,我也无法隐藏它。关于如何做到这一点有任何帮助(或想法)吗?
I have a counter set like this:
<ul>
<li id="cenMill">0</li>
<li id="decMill">0</li>
<li id="uniMill">0</li>
<li id="cen">3</li>
<li id="dec">2</li>
<li id="uni">1</li>
</ul>
- 0
0
0
3
2
1
My intention is to have each number change according to a variable I give it, that is if I add +1 then just change id="uni" from 1 to 2 but if I gave it 12 then change both that are affected and so on. However I don't know how to start to do this so far this is what I have:
$('#uni').animate({
marginTop: "-25px",
},200);
But this only places the 1 to the top, it doesn't make a "2" pop from underneath as the next number and the 1 is visible and I can't hide it even with display, "none" or others like it. Any help (or ideas) as to how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能类似于您想要实现的目标:
数字股票代码演示。
这是一个仓促的复制粘贴:http://damienhowley.wordpress.com/2009/06 /29/jquery-number-ticker/
即使您不能按原样使用它,它也应该为您提供一些如何创建自己的指示。祝你好运。
This might be similar to what you are trying to achieve:
Number ticker demo.
It's a hasty copy-paste from: http://damienhowley.wordpress.com/2009/06/29/jquery-number-ticker/
Even if you can't use it as is, it should give you some pointers on how to create your own. Good luck.