JSFiddle - React, Tailwind, and code Playground

by lazybios

HTML

<div class='button'>add</div>

<div id='result'></div>

CSS

.button {
    border: 1px solid black;
    padding: 10px;
    display: inline-block;
}
.box {
    width: 100px;
    height: 100px;
    background: tomato;
    margin: 5px;
    padding: 5px;
}
.box2 {
    width: 50px;
    height: 50px;
    background: teal;
}
.box3 {
    width: 50px;
    height: 50px;
    background: green;
}

JavaScript

$(document).ready(function() {
    $('body').on('click', '.box *', function() {
        alert($(this).attr('class'));
    });
    $('.button').on('click', function() {
        $('#result').append(
            "<div class='box'>" 
            +"<div class='box2'>"
            +"</div><div class='box3'>"
            +"</div></div>"
        );
    });
});