JSFiddle - React, Tailwind, and code Playground

by loktar

HTML

<div id="counter">0</div>
<a href="#">Click</a>

JavaScript

$(function() {
    var current = $('#counter').text();
    var endvalue = 50;

    function increment() {
        if (current !== endvalue) {
            current++;
            $('#counter').text(current)
            setTimeout(increment, 50);
        }
        
    }

    $('a').click(function() {
        increment();
    })
})