JSFiddle - React, Tailwind, and code Playground
by techiedelight
HTML
<!doctype html>
<html>
<body>
<div id="container"></div>
<div>
<button id="submit">Create Checkbox</button>
</div>
</body>
</html>
CSS
p,
label {
font: 15px 'Exo 2', sans-serif;
}
input {
margin: 6px;
}
button {
margin-top: 10px;
padding: 2 2;
font: 15px 'Exo 2', sans-serif;
}
JavaScript
document.getElementById('submit').onclick = function() {
var checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.id = 'car';
checkbox.name = 'interest';
checkbox.value = 'car';
var label = document.createElement('label')
label.htmlFor = 'car';
label.appendChild(document.createTextNode('Car'));
var br = document.createElement('br');
var container = document.getElementById('container');
container.appendChild(checkbox);
container.appendChild(label);
container.appendChild(br);
}