JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button" value=" Toggle Timer " />
<br/>
<div>0</div>

JavaScript

(function() {    
    var switcher;
    function count() {
        $("div").html(1 + parseInt($("div").html(), 10));
    }
    $(function() {
        switcher = setInterval(count, 1000);
        $("input").toggle(function() { 
            clearInterval(switcher);
            $("div").toggle(); }, 
        function() {                        
            switcher = setInterval(count, 1000);
            $("div").toggle();
        });
    });
}());