JSFiddle - React, Tailwind, and code Playground

HTML

<div id="container"></div>

JavaScript

function Foo(str) {
    // save a reference to "this" to be used in anonymous function
    var that = this; 
    var container = document.getElementById("container");

    this.init = function(){
        var input = document.createElement("input");
        input.type = "button";
        input.value = str;
        
        // on click, call the outer object's function
        input.onclick = that.show_one_more;
        
        container.appendChild(input);   
    }
    
    this.show_one_more = function () {
        // can use "that" here to reference the outer "this"
        alert(str);
    }
}

new Foo("abc").init();
new Foo("123").init();
new Foo("aaa").init();
new Foo("lll").init();