I am new to using code and have put a counter in my website. I need to put a plus sign at the at the end of one of the numbers. How would I go about doing this?Here is what I have injected:var a = 0;$(window).scroll(function() { var oTop = $('#counter').offset().top - window.innerHeight; if (a == 0 && $(window).scrollTop() > oTop) { $('.counter-value').each(function() { var $this = $(this), countTo = $this.attr('data-count'); $({ countNum: $this.text() }).animate({ countNum: countTo }, { duration: 1500, easing: 'swing', step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); } }); }); a = 1; }});<div id="counter"> <div class="sqs-col sqs-col-4 counter-value">0</div> <div class="sqs-col sqs-col-4 counter-value">0</div> <div class="sqs-col sqs-col-4 counter-value">0</div></div> .counter-value { font-size: 40px;color:rgb(250,117,34); line-height:2em; text-align:center; padding:10px 0; } .counter-value:after { content: attr(data-desc); display:block; text-transform:uppercase; font-size: 14px;color:black; line-height:1.2em; } 我的尝试: 再一次,我是新人,所以我还没有尝试过任何东西。What I have tried:Again, I am new so I haven't really tried anything.推荐答案(窗口).scroll(function(){ var oTop =(window).scroll(function() { var oTop =('#counter')。offset()。top - window.innerHeight; if(a == 0&&('#counter').offset().top - window.innerHeight; if (a == 0 &&(窗口).scrollTop()> oTop){(window).scrollTop() > oTop) { 这篇关于如何在计数器的结果中插入加号(+)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-22 21:38