JavaScript计数器将变为0,而不是给定的数字[关闭]

问题描述 投票:1回答:1

根据选民编辑:

我现在的主要问题是,我在Java中创建了一个计数器。假设页面加载时数字从0到给定数字,如此处示例所示:https://codepen.io/corpid/pen/poJERBM

[它在该页面中就像一个符咒一样工作...在codepen.io中,

当我将其添加到我的wordpress网站时,当我加载Web时,计数器没有从0增加到给定的数字(有3个不同的数字),而是从给定的数字变为了0 ...它像倒数一样倒退到0

例如,第一个项目应该从0到500,但是它从500到0。...仅在我的网络上,因为在Codepen中它可以正常工作...

看到网页的问题是:https://webreviewing.com/CCMS

这是功能

$('.count').each(function (thousands_sep) {
    $(this).prop('Counter',0).animate({
        Counter: $(this).text()
    }, {
        duration: 1000,
        easing: 'swing',
        step: function (now) {
            $(this).text(Math.ceil(now));
        }
    });
});
javascript jquery jquery-plugins
1个回答
1
投票

const numberWithCommas = number => number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');

console.log(numberWithCommas(1500));
© www.soinside.com 2019 - 2024. All rights reserved.