JSFiddle - React, Tailwind, and code Playground

by Minko Gechev

HTML

<div class="parent"></div>

CSS

.parent {
    width: 180px;
    height: 180px;
    background-color: #D1A0E7;
    overflow: hidden;
}

.child {
    width: 30px;
    height: 30px;
    background-color: #F6E0FF;
    margin: 5px;
    margin-bottom: 0px;
    margin-right: 0px;
    display: inline-block;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

JavaScript

$('.parent').on('click', '.child', function (e) {
    alert('Child ' + $(this).text() + ' clicked!');
    e.stopImmediatePropagation();
});
var current = 0;
$('.parent').click(function () {
    $(this).append('<div class="child">' + ++current + '</div>');
});