如何在计数器的结果中插入加号(+)? [英] How do I insert a plus sign (+) in the result of a counter?

查看:71
本文介绍了如何在计数器的结果中插入加号(+)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手使用代码并在我的网站上放置了一个计数器。我需要在其中一个数字的末尾添加一个加号。我该怎么做呢?



这是我注入的:






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) {


这篇关于如何在计数器的结果中插入加号(+)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆