JSFiddle - React, Tailwind, and code Playground
by calder12
HTML
<p class="clock"><span id="seconds"></span></p>
<p id="test"></p>
JavaScript
var seconds = 0;
var boolean = 0;
$(document).keypress(function(e) {
if(e.which == 32) {
if(boolean == 0)
{
boolean = 1;
$("#test").html("started " = boolean);
var secondCounter = setInterval( function(){
seconds++;
$("#seconds").html(seconds);
}, 1000);
} else {
boolean = 0;
$("#test").html("stopped " +boolean);
clearInterval(secondCounter);
}
}
});