JSFiddle - React, Tailwind, and code Playground

by Vinod Dalvi

HTML

<body>
        <button type="button" id="click-me">Click me</button>
        <div id="first" class="common-css"></div>
    </body>

CSS

.common-css{
    width: 100px;
    height: 100px;
    background-color: red;
}

JavaScript

document.getElementById('click-me').onclick = function() {
   var newdiv = document.createElement('div');
   var divclassname = 'common-css';
  var firstdiv = document.getElementById('first');
    
  newdiv.setAttribute('class',divclassname);

    firstdiv.appendChild(newdiv);
};