数字滚动
数字滚动
1、简易效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <p class="counter-value">350000</p> <p class="counter-value">50000</p> <p class="counter-value">250000</p> </body> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script> // 数字滚动 function numInit(start) { $('.counter-value').each(function () { $(this).prop('Counter', 0).animate({ Counter: $(this).text() }, { duration: 2500, easing: 'swing', step: function (now) { $(this).text(now.toFixed(0)); } }); }); } numInit(); </script> </html>
2、初始化加载+定时刷新增加数值