Wix Tutorial - Number Counter, using Wix Code

Add a simple number counter to your site using Wix Code.

 

You can change the starting number by changing startNum in the code, and change the end number by changing endNum in the code. You can also experiment with the counter speed by varying const duration.

Elements:

​​Elements:

  • Start Number: #StartNumber

Wix Code:

$w.onReady(function () {});

let startNum = 0;

let endNum = 1000;

const duration = 300;

 

$w.onReady(function () {

    setInterval(() => {

        countUp();

    }, duration);

});

 

function countUp() {

    if (startNum <= endNum) {

        $w('#StartNumber').text = startNum.toString();

        startNum++;

    }

}

Demo:

Start Number

Number Counter