Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

261
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda