El código no está optimizado, primero quiero hacerlo todo.
Funcionalidad deseada? Generar este código: <p> <input></input>
Problema? Se genera <p> </p> <input></input> (Se añade automáticamente la etiqueta de cierre)
Código
<html> <body> <div id="inputs"></div> <script> function añadirEtiqueta(etiqueta, idPadre) { document.getElementById(idPadre).innerHTML += etiqueta; } function p(IDpadre, texto) { if (texto === undefined) texto = ""; añadirEtiqueta("<p>" + texto, IDpadre); } function finp(IDpadre, texto) { if (texto === undefined) texto = ""; añadirEtiqueta(texto + "</p>", IDpadre); } function crearElemento(etiqueta, IDpadre, tipo, valor, id, nombre, fuente, clase, pista, enClick, dentro) { if(!etiqueta) throw new SyntaxError("El parámetro etiqueta está sin definir."); if(!IDpadre) throw new SyntaxError("El parámetro padre está sin definir."); var elemento = document.createElement(etiqueta); elemento.type = tipo; elemento.value = valor; elemento.id = id; elemento.name = nombre; elemento.src = fuente; elemento.class = clase; elemento.placeholder = pista; elemento.onclick = enClick; elemento.innerHTML = dentro; document.getElementById(IDpadre).appendChild(elemento); } /* 1etiqueta, 2IDpadre, 3tipo, 4valor, 5id, 6nombre, 7fuente, 8clase, 9pista, 10enClick, 11dentro */ var i = 1; var d1 = "inputs"; p(d1, "DOMINIOS: "); crearElemento("input", d1, "text", "", "", "Dominio"+i, "", "", "https://example.com/" , "", ""); finp(d1); </script> </body> </html>