JSFiddle - React, Tailwind, and code Playground
HTML
<title>Untitled Document</title>
<body>
<div id="teste">
<h1>adicionando elementos dinamicamente</h1>
<input type="text" id="valor" />
<button id="p1">adicionar p</button>
</div>
</body>
JavaScript
var a = document.getElementById("p1");
function criar() {}
criar.prototype.getValue = function () {
return document.getElementById("valor").value;
};
criar.prototype.luz = function() {
var b = document.createElement("h1");
var pai = document.body;
var texto = document.createTextNode(this.getValue());
b.appendChild(texto)
pai.appendChild(b)
}
criar = new criar();
a.onclick = function() {
criar.luz()
}