JSFiddle - React, Tailwind, and code Playground
HTML
<button onclick='myFunction()'>asd</button>
<div id="demo"></div>
CSS
button {
height:20px;
width: 50px;
}
JavaScript
function myFunction() {
document.getElementById('demo').innerHTML = '';
var num = 5;
var noOfButtons = Math.floor(Math.random() * num);
console.log(noOfButtons);
for (var i = 0; i < noOfButtons; i++) {
var box = document.createElement("BUTTON");
document.getElementById('demo').appendChild(box);
}
}