Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
how to create a text box when button is pressed in Js?

I want to create a button in JS and when you press it, it will create a text box above the button. But the number of textboxes is unknown. is it possible? Thank you

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can do it like this:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Ronak</title>
</head>
<body>
  <div id="textboxContainer">
  </div>
  <button onclick="addTextbox(event)">Click Me!</button>
  
  <script type="text/javascript">
    function addTextbox(event) {
          var input = document.createElement("input");
          input.setAttribute("type", "text");
          document.getElementById("textboxContainer").appendChild(input);
    }
  </script>
</body>
</html>

about 4 years ago · Juan Pablo Isaza Denunciar

0

There are one way. You have to append it. With Jquery it is something like this:

<html>
<body>
    <button></button>
    <p id="new"></p>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>    
$("button").click(()=>{
    $("p#new").append("Your input textbox<input ---/>")
    })
</script>
</body>
</html>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda