[英]How can I add two CountUp elements
On my website Im trying to add two CountUp timers.在我的网站上,我尝试添加两个 CountUp 计时器。 First is working OK, but with second timer Im having a lot of problem.
第一个工作正常,但是第二个计时器我有很多问题。 As Im working with wordpress ID is strange 🙂
因为我使用 wordpress ID 很奇怪 🙂
I allready created code for both timers but as I said, second one doesnt work.我已经为两个计时器创建了代码,但正如我所说,第二个不起作用。 I think the problem could be with finding this element...
我认为问题可能在于找到这个元素......
var getID = $( element ).attr('id');
var getIDCurr = $( element ).attr('#1523517692376-5f09ae62-8203')
$(element).on( 'inview', function(){
var numAnim = new CountUp( getID , 0, getCounter, 0, 0, options);
if (!numAnim.error) {
numAnim.start();
} else {
console.error(numAnim.error);
}
var numCurr = new CountUp( getIDCurr , 0, 100, 0, 0, options);
if (!numCurr.error) {
numCurr.start();
} else {
console.error(numCurr.error);
}
} );
And HTML和 HTML
<div class="de-sc-milestone__count uk-scrollspy-inview" id="1523517692376-5f09ae62-8203" data-start-counter="323626.20" data-symbol="<span class='de-sc-milestone__symbol'><sup>€</sup></span>" data-symbol-position="suffix" style="">323,626<span class="de-sc-milestone__symbol"><sup>€</sup></span></div>
I hope anyone knows the solution...希望有人知道解决办法...
Found solution.找到解决方案。 I changed
我变了
var getIDCurr = $( element ).attr('#1523517692376-5f09ae62-8203')
to到
var getIDCurr = $( element ).id='1523517692376-5f09ae62-8203';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.