1234class="itemBox-left"style="font-style:normal" class="timer count-title" id="count-number27" data-to="100" data-speed="1000"1000<!----> id="addTxt"
1
12345678910111213141516171819202122232425262728293031323334353637383940414243let num = 0function changeNum() {$.fn.countTo = function(a) {a = a || {};return $(this).each(function() {var c = $.extend({},$.fn.countTo.defaults, {from: $(this).data("from"),to: $(this).data("to"),speed: $(this).data("speed"),refreshInterval: $(this).data("refresh-interval"),decimals: $(this).data("decimals")}, a);var h = Math.ceil(c.speed / c.refreshInterval),i = (c.to - c.from) / h;var j = this,f = $(this),e = 0,g = c.from,d = f.data("countTo") || {};f.data("countTo", d);if (d.interval) {clearInterval(d.interval)}d.interval = setInterval(k, c.refreshInterval);b(g);function k() {g += i;e++;b(g);if (typeof(c.onUpdate) == "function") {c.onUpdate.call(j, g)}if (e >= h) {f.removeData("countTo");clearInterval(d.interval);g = c.to;if (typeof(c.onComplete) == "function") {c.onComplete.call(j, g)}}
将以上代码复制到页面,并且自己写好判断条件,即可使用