JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id='txt' readonly rows='5' cols='40'></textarea>
<button id='btn' type='button'>click</button>
JavaScript
var btn = document.getElementById('btn');
var txt = document.getElementById('txt');
var foo = new Foo(btn);
function Foo(btn) {
this.button = btn;
}
Foo.prototype.buy = function() {
txt.value = 'Foo Bar';
};
Foo.button.onclick = function() {
foo.buy();
};