JSFiddle - React, Tailwind, and code Playground
HTML
<div id='js-out'></div>
<div id='js-example'></div>
JavaScript
function makeButton(functionIn, text, flag){
var button = document.createElement('BUTTON');
var btTxt = document.createTextNode(text);
button.onclick = functionIn;
button.setAttribute('flag', flag);
button.appendChild(btTxt);
document.getElementById('js-out').appendChild(button);
}
var buttonFunctionOne = function() {
console.log(this);
}
var buttonFunctionTwo = function() {
console.log(this);
}
makeButton(buttonFunctionOne,'button one', '1');
makeButton(buttonFunctionOne,'button two', '0');
makeButton(buttonFunctionTwo,'button three', '1');