admin管理员组文章数量:1387286
I tried to use countup.js - I used it several times in the past, but now it is not working anymore. Does anybody see the mistake?
HTML:
<div id="counter">1000</div>
JS:
function countup() {
var options = {
useEasing: true,
useGrouping: true,
separator: '.',
decimal: ',',
suffix: 'People'
};
var demo = new CountUp('counter', 0, $("#counter").text(), 2, 4, options);
if (!demo.error) {
demo.start();
} else {
console.error(demo.error);
}
}
countup();
Here is the codepen:
I tried to use countup.js - I used it several times in the past, but now it is not working anymore. Does anybody see the mistake?
HTML:
<div id="counter">1000</div>
JS:
function countup() {
var options = {
useEasing: true,
useGrouping: true,
separator: '.',
decimal: ',',
suffix: 'People'
};
var demo = new CountUp('counter', 0, $("#counter").text(), 2, 4, options);
if (!demo.error) {
demo.start();
} else {
console.error(demo.error);
}
}
countup();
Here is the codepen: https://codepen.io/anon/pen/PrGvvK
Share Improve this question edited Jun 19, 2019 at 8:51 Maximilian Neuse asked Jun 19, 2019 at 8:47 Maximilian NeuseMaximilian Neuse 1631 gold badge5 silver badges15 bronze badges 4- 1 Check the console in your Codepen, there's several issues – Rory McCrossan Commented Jun 19, 2019 at 8:48
- 1 Also, your not actually successfully importing the CountUp library... – Alicia Sykes Commented Jun 19, 2019 at 8:51
- @RoryMcCrossan Unfortunalety I have no idea how to solve these problems. – Maximilian Neuse Commented Jun 19, 2019 at 8:52
- @Alicia what is wrong? I added them via external scripts? – Maximilian Neuse Commented Jun 19, 2019 at 8:53
2 Answers
Reset to default 3add countUp.js in your Code:
<script src='https://cdnjs.cloudflare./ajax/libs/countup.js/1.8.2/countUp.min.js'></script>
Working Demo
In your codepen example you are using version 2.0.4 (https://cdnjs.cloudflare./ajax/libs/countup.js/2.0.4/countUp.min.js) which uses ES6
code. You can see the error message in console.
Uncaught SyntaxError: Unexpected token export
browsers doesn't have full ES6 support. So if you use version 1.8.2
which doesn't use ES6 code it will work via external script.
Below is the codepen using older version
https://codepen.io/anon/pen/dBpxbd
本文标签: javascriptCountUpjs not starting to count upStack Overflow
版权声明:本文标题:javascript - CountUp.js: not starting to count up - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744541573a2611644.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论