> For the complete documentation index, see [llms.txt](https://javascriptuse.gitbook.io/javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://javascriptuse.gitbook.io/javascript/numscroller-counter-from-zero-to-value-javascript-animation-ok.md).

# NumScroller, Counter From Zero To Value - Javascript Animation (ok)

### Example 0

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <section class="numbers">
    <div class="container" id="main">
      <h6 class="red-title">BY THE NUMBERS</h6>
      <h2 class="stats-heading">We’ll always measure up to your expectations</h2>
      <div class="numbers-box">
        <h1 class="count" max-data="50">30</h1>
        <h6>years of experience</h6>
      </div>
      <div class="numbers-box">
        <h1 class="count" max-data="37">0</h1>
        <h6>countires supplied</h6>
      </div>
      <div class="numbers-box">
        <h1 class="count" max-data="128">0</h1>
        <h6>group automation employees</h6>
      </div>
    </div>
  </section>
  <script>
    var runAlready;
    var counting;
    function startCounter(a) {
      runAlready = true;
      counting = true;
      $('.count').each(function () {
        var $this = $(this);
        $this.text(a);
        countTo = $this.attr('max-data');
        $({
          countNum: $this.text()
        }).animate({
          countNum: countTo
        },
        {
          duration: 2000,
          easing: 'swing',
          step: function () {
            $this.text(Math.floor(this.countNum));
          },
          complete: function () {
            $this.text(this.countNum);
            counting = false;
          }
        });
      })
    }
    $(window).scroll(function () {
      var oTop = $('#main').offset().top;
      var a = 0;
      if (!runAlready && $(window).scrollTop() > oTop || !counting && $(window).scrollTop() < oTop) {
        startCounter(a);
      }
    });
  </script>
</body>
</html>
```

```scss
.counter-box {
  display: block;
  background: #f6f6f6;
  padding: 40px 20px 37px;
  text-align: center
}
.counter-box p {
  margin: 5px 0 0;
  padding: 0;
  color: #909090;
  font-size: 18px;
  font-weight: 500
}
.counter {
  display: block;
  font-size: 32px;
  font-weight: 700;
  color: #666;
  line-height: 28px
}
.counter-box.colored {
  background: #eab736;
}
.counter-box.colored p,
.counter-box.colored .counter {
  color: #fff;
}
```

<figure><img src="/files/QnAFyraLD1jArnSDbWNM" alt=""><figcaption></figcaption></figure>

### Example 1&#x20;

{% embed url="<https://www.youtube.com/watch?v=eMtebHRQaM4>" %}

C:\Users\Administrator\Documents\Lorem\index.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <section id="main" class="main">
    <div class="container">
      <div class="count-heading">
        <div class="count" max-data="10">1</div>
        <h2>Project</h2>
      </div>
      <div class="count-heading">
        <div class="count" max-data="20">1</div>
        <h2>Project</h2>
      </div>
      <div class="count-heading">
        <div class="count" max-data="30">1</div>
        <h2>Project</h2>
      </div>
      <div class="count-heading">
        <div class="count" max-data="40">1</div>
        <h2>Project</h2>
      </div>
    </div>
  </section>
  <script>
    var count = document.getElementsByClassName("count");
    var inc = [];
    function intervalFunc() {
      for (let i = 0; i < count.length; i++) {
        inc.push(1);
        if (inc[i] != count[i].getAttribute("max-data")) {
          inc[i]++;
        }
        count[i].innerHTML = inc[i];
      }
    }
    var main = document.getElementById("main");
    window.onscroll = function () {
      var timer = setInterval(() => {
        var topElem = main.offsetTop;
        var btmElem = main.offsetTop + main.clientHeight;
        var topScreen = window.scrollY;
        var btmScreen = window.scrollY + window.innerHeight;
        // console.log(btmScreen);
        if (btmScreen > topElem && topScreen < btmElem) {
          intervalFunc();
        } else {
          clearInterval(timer);
          for (let i = 0; i < count.length; i++) {
            count[i].innerHTML = 1;
            inc = [];
          }
        }
      }, 100);
    }
  </script>
</body>
</html>
```

C:\Users\Administrator\Documents\Lorem\style.scss

```scss
body {
  padding: 0;
  margin: 0;
  height: 1500px;
}
.main {
  background-color: #fff;
  padding: 20px 0;
}
.container {
  padding: 0 5%;
  margin: 0 auto;
  display: flex;
}
.count-heading {
  flex: 1;
  font-size: 40px;
  text-align: center;
  border: 2px solid red;
  background-color: pink;
  color: #fff;
}

```

<figure><img src="/files/8DFhcCAN90hWUc0Lqt1c" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/G9x032JE3jjWXbRBMSsh" alt=""><figcaption></figcaption></figure>

### Example 2

```
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="test4.css">
  <title>Document</title>
</head>

<body>
  <a href="https://www.i-visionblog.com/2022/05/odometerjs-animated-number-counter-from.html" class="linker">New Updated Tutorial: Odometer.js Animated Number Counter From Zero To Value - JavaScript Animation Part 2 - i-visionblog </a>
  <div class="shiva">
    <div class="shiva__left">
      <span class="count">200</span><span class="text">Text</span>
    </div>
    <div class="shiva__right">
      Lorem, ipsum, dolor.
    </div>
  </div>
  <div class="shiva">
    <div class="shiva__left">
      <span class="count">1000</span><span class="text">Text</span>
    </div>
    <div class="shiva__right">
      Lorem, ipsum, dolor.
    </div>
  </div>
  <div class="shiva">
    <div class="shiva__left">
      <span class="count">853</span><span class="text">Text</span>
    </div>
    <div class="shiva__right">
      Lorem, ipsum, dolor.
    </div>
  </div>
  <div class="shiva">
    <div class="shiva__left">
      <span class="count">154</span><span class="text">Text</span>
    </div>
    <div class="shiva__right">
      Lorem, ipsum, dolor.
    </div>
  </div>
  <div class="shiva">
    <div class="shiva__left">
      <span class="count">10</span><span class="text">Text</span>
    </div>
    <div class="shiva__right">
      Lorem, ipsum, dolor.
    </div>
  </div>
  <div class="shiva">
    <div class="shiva__left">
      <span class="count">87</span><span class="text">Text</span>
    </div>
    <div class="shiva__right">
      Lorem, ipsum, dolor.
    </div>
  </div>
  <div style="clear:both"></div>
  <div id="talkbubble"><span class="count">1421</span></div>
  <div id="talkbubble"><span class="count">145</span></div>
  <div id="talkbubble"><span class="count">78</span></div>
  <br />
  <br />
  <a class="linker" href="http://www.i-visionblog.com/2014/11/jquery-animated-number-counter-from-zero-to-value-jquery-animation.html" target="_blank">visit Tutorial in Blog</a>
  <br />
  <script src="//code.jquery.com/jquery-3.7.1.min.js"></script>
  <script type="text/javascript">
  $('.count').each(function() {
    $(this).prop('Counter', 0).animate({
      Counter: $(this).text()
    }, {
      duration: 4000,
      easing: 'swing',
      step: function(now) {
        $(this).text(Math.ceil(now));
      }
    });
  });
  </script>
</body>

</html>
```

```
.shiva {
  width: 100px;
  height: 100px;
  background: red;
  -moz-border-radius: 50px;
  -webkit-border-radius: 50px;
  border-radius: 50px;
  float: left;
  margin: 5px;
}
.count {
  line-height: 100px;
  color: white;
  margin-left: 30px;
  font-size: 25px;
}
#talkbubble {
  width: 120px;
  height: 80px;
  background: white;
  position: relative;
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
  float: left;
  margin: 20px;
}
#talkbubble:before {
  content: "";
  position: absolute;
  right: 100%;
  top: 26px;
  width: 0;
  height: 0;
  border-top: 13px solid transparent;
  border-right: 26px solid white;
  border-bottom: 13px solid transparent;
}
.linker {
  font-size: 20px;
  font-color: black;
}
```

### Example 3

{% embed url="<https://github.com/tinywall/numscroller>" %}

<figure><img src="/files/MNGQwKcGSOaioB1XL5ij" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://javascriptuse.gitbook.io/javascript/numscroller-counter-from-zero-to-value-javascript-animation-ok.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
