Click here to Skip to main content
15,904,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:



HTML
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.
Posted
Updated 7-Aug-18 23:57pm
v2

1 solution

Try
$this.text(this.countNum + "+");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900