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

Websites designed by WixCreate that use the above Wix Code:

None

Official Wix Expert & Wix Agency Partner

© 2020 by WIXCreate.com

I  All Rights Reserved  I  info@wixcreate.com  I  202-640-5440

facebook-2.gif