JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
<script>
function bind(base, el, varname) {
Object.defineProperty(base, varname, {
get: () => {
return el.value;
},
set: (value) => {
el.value = value;
}
})
}
function thing() {
}
p = new thing();
document.addEventListener("DOMContentLoaded",()=>{
bind(p, document.getElementById("toBind"), "potato");
setInterval(()=>{document.getElementById("value").innerText=p.potato});
});
</script>
</head>
<body>
<input id="toBind">
<p>
The value of the variable is <span id="value"></span>
</p>
</body>
</html>