jquery 实现数字动态变化
作者:互联网
直接上代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery.min.js"></script>
</head>
<body>
<div class="count">当前在线人数:<span id="number" style="color:red;font-size: 16px;font-weight: bold;">
</span>
</div>
<script type="text/javascript">
function magic_number(value,num) {
num.animate({ count: value }, {
duration: 1000, //持续时间
step: function () {
num.text(Math.round(this.count));
}
});
};
var num = 2;
setInterval(function(){magic_number(num+=10, $("#number"));},2000);
</script>
</body>
</html>
标签:jquery,function,magic,数字,动态变化,number,value,num,count 来源: https://blog.csdn.net/weixin_43025071/article/details/111524189