let arr = []
$('变化的元素').each(function (index, item) {
let a = $(item).attr('attr-num')
arr.push(a)
})
// 或者
let arr = [111,2222,3333]
$('变化的元素').each((index, item) => {
let num = 0
let per = (2000 / arr[index]) < 10 ? 10 : 2000 / arr[index] // 总时间为2s
let up = arr[index] > 1000 ? arr[index] / 200 : 1 // 比较大的数字
let time = setInterval(function () {
num += up
$(item).html(parseInt(num))
if (num >= arr[index]) {
$(item).html(arr[index])
clearInterval(time)
}
}, per)
})
html5简单的数字加法效果
最新推荐文章于 2023-05-28 21:28:51 发布