JSFiddle - React, Tailwind, and code Playground

HTML

<div id="container"></div>
<span id="time"></span>

JavaScript

var cb = document.createElement('input');
cb.type = "checkbox";
cb.name = "name";
cb.value = "value";
cb.id = "id";
cb.addEventListener("click", showTime, false);

var lbl = document.createElement('label')
lbl.htmlFor = "id";
lbl.appendChild(document.createTextNode("show time"));

var container = document.getElementById('container');
container.appendChild(cb);
container.appendChild(lbl);

var sp = document.getElementById('time');

function showTime() {
    if (this.checked) {
        var today = new Date()
        sp.innerHTML = today.toString();
    } else {
        sp.innerHTML='';
    }
}