JSFiddle - React, Tailwind, and code Playground

HTML

<div>Click a button. See the assigned value here : <span id="status"></span></div>
<div id="button_out_1"></div>

CSS

button {
    height: 50px;
    width: 100px;
    margin:10px;
}

JavaScript

function buttonClicked( num )
{
    document.getElementById("status").innerText = num;
}

for(var i = 0; i < 16; i++)
{
    var el = document.createElement("button");
    
    el.onclick = (function( num ) {
        return function ( e ) {
            buttonClicked( num, e );
        }
    })( i );
    
    document.getElementById("button_out_1").appendChild(el);
}
/*  NOTE: this method can be automated using a helper function like so:

function evarg(func) {
	var args = Array.prototype.slice.call(arguments, 1);
	return function(event) {
		func.apply(null, args.concat([event]));
	};
}

USAGE: el.onclick = evarg( buttonClicked, num );
*/